我在DB中创建了一个表,该表名为工作流,其中包含名为document的二进制字段,如何将文档上载到此字段,以便以后使用.
OpenFileDialog ofd = new OpenFileDialog();
RapidWorkflowDataContext context = new RapidWorkflowDataContext();
private void buttonOpen_Click(object sender, EventArgs e)
{
if (ofd.ShowDialog() == DialogResult.OK && ofd.FileName.Length > 0)
{
}
}
发布于 2013-08-14 18:39:03
如果不知道Workflows
表的架构,则如下所示:
Stream myStream = openFileDialog1.OpenFile();
if (myStream != null)
{
using (myStream)
{
Workflows w = new Workflows();
byte[] bytes = new byte[myStream.Length];
myStream.Read(bytes, 0, (int)myStream.Length);
// change here to your actual field name
w.FileData = bytes;
// change here according to your context
context.Workflows.Add(w);
context.SubmitChanges();
}
}
https://stackoverflow.com/questions/18245347
复制