在sql server中存储图像的问题 [英] Problem with storing images in sql server
本文介绍了在sql server中存储图像的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将图像存储在数据类型为 image
的 sql server 中,现在问题是存储到两行中,我使用 FileUpload 控件上传图像,我的代码如下
I am trying to store images in sql server with data type image
now the problem is getting stored into two rows, i am using FileUpload control to upload image, my code is as follows
byte[] imagedata = ImageUpload.FileBytes;
con.Open();
SqlCommand insertImageCmd = new SqlCommand("insert into Images(ImageName,Image) values (@name, @image)", con);
insertImageCmd.Parameters.AddWithValue("@name", imageNameTextBox.Text);
insertImageCmd.Parameters.AddWithValue("@image", imagedata );
insertImageCmd.ExecuteNonQuery();
con.Close();
这是存储图像的正确方式吗?请帮忙!
is this the correct way store images? please help!
推荐答案
如果使用您发布的代码将其存储为两行,我认为您可能会以某种方式重复发布您的页面.
If its getting stored as two rows, using the code you've posted, I think that you might somehow be double posting your page.
这篇关于在sql server中存储图像的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文