sqlserver数据库中img类型的二进制数据怎么转换成图片,再怎么把图片转换成这个类型的二进制数据
答案:1 悬赏:10
解决时间 2021-02-11 20:22
- 提问者网友:巴黎塔下许过得承诺
- 2021-02-11 03:14
sqlserver数据库中img类型的二进制数据怎么转换成图片,再怎么把图片转换成这个类型的二进制数据
最佳答案
- 二级知识专家网友:迷人小乖乖
- 2021-02-11 04:47
C# 保存
openFileDialog1.Filter = "*jpg|*.JPG|*.GIF|*.GIF|*.BMP|*.BMP"; if(openFileDialog1.ShowDialog()==DialogResult.OK) {
string fullpath =openFileDialog1.FileName;//文件路径 FileStream fs = new FileStream(fullpath, FileMode.Open); byte[] imagebytes =new byte[fs.Length]; BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length)); //打开数据库
SqlConnection con = new
SqlConnection("server=(local);uid=sa;pwd=;database=test"); con.Open();
SqlCommand com = new SqlCommand("insert into tb_08 values(@ImageList)",con);
com.Parameters.Add("ImageList", SqlDbType.Image); com.Parameters["ImageList"].Value = imagebytes; com.ExecuteNonQuery(); con.Close();
openFileDialog1.Filter = "*jpg|*.JPG|*.GIF|*.GIF|*.BMP|*.BMP"; if(openFileDialog1.ShowDialog()==DialogResult.OK) {
string fullpath =openFileDialog1.FileName;//文件路径 FileStream fs = new FileStream(fullpath, FileMode.Open); byte[] imagebytes =new byte[fs.Length]; BinaryReader br = new BinaryReader(fs);
imagebytes = br.ReadBytes(Convert.ToInt32(fs.Length)); //打开数据库
SqlConnection con = new
SqlConnection("server=(local);uid=sa;pwd=;database=test"); con.Open();
SqlCommand com = new SqlCommand("insert into tb_08 values(@ImageList)",con);
com.Parameters.Add("ImageList", SqlDbType.Image); com.Parameters["ImageList"].Value = imagebytes; com.ExecuteNonQuery(); con.Close();
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯