将图片从sql数据库中检索到图片框中 [英] Retrieving a picture from sql database into a picturebox
问题描述
我想从SQL Server(数据库)中检索图像并将其设置为图片框图像属性。
if(FileUpload1.HasFile)
{
String str = Fileupload1.FileName;
Fileupload1.PostedFile.SaveAs(Server.MapPath(。)+// Image //+ str);
String path =// Image //+ str.ToString();
Sc.Open();
SqlCommand cmd = new SqlCommand(插入图像值('+ Txtname.Text +','+ path +'),Sc);
Cmd.ExecuteNonquery();
Sc.Close();
Label1.Text =inserted;
}
其他
{
Label1.Text =未插入;
}
如何检索图像从数据库到图片框
I want to retrieve image from SQL Server(Database) and set it to Picture Box Image Property .
if (FileUpload1.HasFile)
{
String str=Fileupload1.FileName;
Fileupload1.PostedFile.SaveAs(Server.MapPath(".")+"//Image//"+str);
String path="//Image//"+str.ToString();
Sc.Open();
SqlCommand cmd=new SqlCommand("Insert into Image values('"+Txtname.Text+"','"+path+"')",Sc);
Cmd.ExecuteNonquery();
Sc.Close();
Label1.Text="inserted";
}
else
{
Label1.Text="Not inserted";
}
how to retrieve image from database to picturebox
推荐答案
尝试
使用ASP.Net从SQL Server数据库显示图像 [ ^ ]
在图像控件中显示数据库中的图像不在ASP.Net中使用Generic Handler [ ^ ]
使用ASP.NET保存并从数据库中检索图像 [ ^ ]
Try
Display Images from SQL Server Database using ASP.Net[^]
Display image from database in Image control without using Generic Handler in ASP.Net[^]
Save and Retrieve Images from the Database using ASP.NET[^]
这篇关于将图片从sql数据库中检索到图片框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!