在Access数据库“attachment”字段中存储文件

时间:2013-10-30 04:25:16

标签: c# database ms-access attachment

我尝试使用以下代码将openFileDialog返回的文件存储到Access数据库中表(付款)的附件字段([photoattached]是字段名称),但我得到了“无效参数“运行时出错。谁能告诉我这是什么问题?

byte[] imageContent = File.ReadAllBytes(openFileDialog.FileName);
var command = conn.CreateCommand();
command.CommandText = @"INSERT INTO payment (photoattached.FileName,photoattached.FileData) VALUES (@Filename,@File)";
command.Parameters.AddWithValue("@FileName", openFileDialog.FileName);
command.Parameters.AddWithValue("@File",imageContent );
command.ExecuteNonQuery();

0 个答案:

没有答案