这个问题太简单了,咱们废话少说,看代码如下:
private OleDbConnection conn;//连接数据库代码
string fullname=this.openFileDialog1.FileName;//打开文件对话框
FileStream fs=File.OpenRead(fullname);
byte [] content=new byte[fs.Length];
fs.Read(content,0,content.Length);
fs.Close();
OleDbCommand com=new OleDbCommand("insert into 表(图片)values(@image)",conn);
com.Parameters.Add("@photo",OleDbType.Binary).Value=content;
com.ExecuteNonQuery();