如何将图像从数据库中提取到网格 [英] how to retieve images from database to grid
问题描述
这是我的代码。
DataSet ds = new DataSet(CpnyLgo);
byte [] MyData = new byte [0];
sda.Fill(ds,CpnyLgo);
DataRow myRow;
myRow = ds.Tables [CpnyLgo]。行[0];
MyData =(byte [])myRow [CompanyLogo];
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image = Image.Fromstream(stream);
此代码是在图片框中上传图片,我需要在网格中上传图片。
我已经使用以下代码上传了剩余价值:
This is my code.
DataSet ds = new DataSet("CpnyLgo");
byte[] MyData = new byte[0];
sda.Fill(ds, "CpnyLgo");
DataRow myRow;
myRow = ds.Tables["CpnyLgo"].Rows[0];
MyData = (byte[])myRow["CompanyLogo"];
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);
This code is to upload the image in picturebox and i need to upload the images in grid.
I have uploaded the rest value by using this code:
int i = 0;//intialises i=0
while(QbReader1.Read())//reading the values
{
radGridView1.Rows.AddNew();//should add new row
//string iStr = QbReader1["CompanyName"].ToString();
radGridView1.Rows[i].Cells[0].Value = QbReader1["CompanyName"].ToString();
radGridView1.Rows[i].Cells[1].Value = Image.FromStream(stream);
radGridView1.Rows[i].Cells[2].Value = QbReader1["State"].ToString();
radGridView1.Rows[i].Cells[3].Value = QbReader1["Country"].ToString();
radGridView1.Rows[i].Cells[4].Value = QbReader1["WebsiteAddress"].ToString();
i++;
}
QbReader1.Close();
请知道答案的人帮助我............
Please Anyone who know the answer help me ............
推荐答案
真的,回答一个被问过很多次的问题并不是那么好: http://www.codeproject.com/search。 ?ASPX q =%28%22.NET%22 + OR +%22C%23%22%29 +数据库+%28image + OR +图像+ OR +位图+ OR +位图%29&安培; doctypeid = 1%3B5 [ ^ ]。
-SA
Really, it would not be so good to answer a question which has been asked so many times: http://www.codeproject.com/search.aspx?q=%28%22.NET%22+OR+%22C%23%22%29+database+%28image+OR+images+OR+bitmap+OR+bitmaps%29&doctypeid=1%3b5[^].
—SA
hi
我得到解决方案。 ....
Da taSet ds = new DataSet(CpnyLgo);
byte [] MyData = new byte [0];
sda.Fill(ds,CpnyLgo);
DataRow myRow;
myRow = ds.Tables [CpnyLgo]。行[0];
MemoryStream stream = new MemoryStream(MyData) ;
picturebox1.Image = Image.Fromstream(stream);
< pre lang =" ; cs"> int i = 0; // intialises i = 0
while(QbReader1.Read())//读取值
{
radGridView1.Rows.AddNew(); //应添加新行
//字符串iStr =
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image = Image.Fromstream(stream);
QbReader1 [& quot; CompanyName& quot ;]。ToString();
radGridView1.Rows [i] .Cells [0] .Value = QbReader1 [& quot; CompanyName& quot;]。ToString ();
radGridView1.Rows [i] .Cells [1] .Value = Image.FromStream(stream);
radGridView1.Rows [i] .Cells [2] .Value = QbReader1 [& quot; State& amp; ; to;]。ToString();
radGridView1.Rows [i] .Cells [3] .Value = QbReader1 [& quot; Country& quot;]。ToString();
radGridView1.Rows [i] .Cells [4] .Value = QbReader1 [& quot; WebsiteAddress& quot;]。ToString();
i ++;
}
QbReader1.Close();
< / pre>
hi
I get the solution.....
DataSet ds = new DataSet("CpnyLgo");
byte[] MyData = new byte[0];
sda.Fill(ds, "CpnyLgo");
DataRow myRow;
myRow = ds.Tables["CpnyLgo"].Rows[0];
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);
<pre lang="cs">int i = 0;//intialises i=0
while(QbReader1.Read())//reading the values
{
radGridView1.Rows.AddNew();//should add new row
//string iStr =
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);
QbReader1["CompanyName"].ToString();
radGridView1.Rows[i].Cells[0].Value = QbReader1["CompanyName"].ToString();
radGridView1.Rows[i].Cells[1].Value = Image.FromStream(stream);
radGridView1.Rows[i].Cells[2].Value = QbReader1["State"].ToString();
radGridView1.Rows[i].Cells[3].Value = QbReader1["Country"].ToString();
radGridView1.Rows[i].Cells[4].Value = QbReader1["WebsiteAddress"].ToString();
i++;
}
QbReader1.Close();
</pre>
这篇关于如何将图像从数据库中提取到网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!