且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在asp.net中从数据库中显示图像控制中的图像

更新时间:2022-06-15 03:21:41

con.Open();

cmd = new OleDbCommand(从购买中选择product_img,其中Model_no ='+ comboBox2.Text +',con);

da = new OleDbDataAdapter(cmd);

ds = new DataSet();

da.Fill(ds);

byte [] MyData = new byte [0];

DataRow myRow;

myRow = ds.Tables [0] .Rows [0];

MyData =(byte [])myRow [0];

MemoryStream stream = new MemoryStream(MyData);

pictureBox1.Image = Image.FromStream(stream);

pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;



con.Close();
con.Open();
cmd = new OleDbCommand("select product_img from purchase where Model_no='" + comboBox2.Text + "'", con);
da = new OleDbDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
byte[] MyData = new byte[0];
DataRow myRow;
myRow = ds.Tables[0].Rows[0];
MyData = (byte[])myRow[0];
MemoryStream stream = new MemoryStream(MyData);
pictureBox1.Image = Image.FromStream(stream);
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;

con.Close();


查看此链接..



示例1 [ ^ ]



示例2 [ ^ ]





问候



Dil
Check this links..

Example 1[^]

Example 2[^]


Regards

Dil


Exacly你想要的:

使用EF在SQL Server中存储二进制数据 [ ^ ]
Exacly what you want :
Storing binary data in SQL Server using EF[^]