我在数据库中创建了一个表,名为Workflows,其中包含名为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)
{
}
}
答案 0 :(得分:0)
在不知道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();
}
}