我想通过一个打开对话框获取一个图片的路径,再把这个图片文件放入sql server2000里后个image字段里,请问下面的代码该如何修改?
OpenFileDialog ff = new OpenFileDialog();
ff.ShowDialog();
photopath = ff.FileName;
this.pictureBox1.Image = Image.FromFile(photopath);
FileInfo finfo = new FileInfo(photopath);
byte[] content = new byte[finfo.Length];
FileStream stream = finfo.OpenRead();
stream.Read(content, 0, content.Length);
stream.Close();
string sql = "update users set photo=" + content + " where userid=1";
Dodatabase.ExecuteSQL(sql);
OpenFileDialog ff = new OpenFileDialog();
ff.ShowDialog();
photopath = ff.FileName;
this.pictureBox1.Image = Image.FromFile(photopath);
FileInfo finfo = new FileInfo(photopath);
byte[] content = new byte[finfo.Length];
FileStream stream = finfo.OpenRead();
stream.Read(content, 0, content.Length);
stream.Close();
string sql = "update users set photo=" + content + " where userid=1";
Dodatabase.ExecuteSQL(sql);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货