我现在想把pdf文档放入数据库,在从数据库中取出显示。谁有示例代码帮忙给以份。我的邮箱cchflydragon@163.com
下面是我的代码帮我看看错在什么地方
//将图片文件存入数据库
private void button1_Click(object sender, EventArgs e)
{
FileStream fs = new FileStream("D:\\12.jpg",FileMode.Open);
BinaryReader br = new BinaryReader(fs);
int len = Convert.ToInt32(br.BaseStream.Length);
byte[] buffer = new Byte[len];
OleDbParameter[] parms = { new OleDbParameter("@info", OleDbType.LongVarBinary) };
parms[0].Value = buffer;
SqlHelper helper = new SqlHelper();
int result = helper.Execute("insert into data(info) values (@info)", parms);
}
//从数据库取出图片文件并显示在picturebox1控件中
private void button2_Click(object sender, EventArgs e)
{
SqlHelper helper = new SqlHelper();
DataSet ds = helper.GetDs("select info from data ");
byte[] buffer = (byte[])ds.Tables[0].Rows[0][0];
MessageBox.Show(Convert.ToString(buffer.Length));
MemoryStream ms = new MemoryStream(buffer,false);
this.pictureBox1.Image = Image.FromStream(ms);
}
最后提示参数无效