I STORED MULTIPLE IMAGES IN MY SQL SERVER 2005. NOW I WANT TO RETRIEVE PARTICULAR CATEGORY OF IMAGES INTO MULTIPLE PICTUREBOX AT RUNTIME IN C# WINDOWS APPLICATION. i used the following code in my final result form at form_Load using c# windows apps.. But it displays only one picture at run time pls help to me...
PLEASE TELL IS IT ANY WRONG WITH THIS CODE?
OR SUGGEST NEW CODE TO ME PLEASE..
Code:
SqlConnection con = new SqlConnection(@"Data Source=ttt-PC;Initial Catalog=Query_Image;Integrated Security=True");
SqlCommand cmdnew = new SqlCommand("select pic from Image_Category where IMG_Cat='" + searchvalue.ToString() + "'", con);
con.Open();
// SqlDataReader dr = cmdnew.ExecuteReader();
SqlDataAdapter da = new SqlDataAdapter(cmdnew);
DataSet ds = new DataSet("Image_Category");
byte[] mydata = new byte[0];
da.Fill(ds, "Image_Category");
DataRow myrow;
//if (dr.HasRows)
//{
// while (dr.Read())
// {
for (int i = 0; i < 2; i++)
// while (i <= dt.Rows.Count)
{
myrow= ds.Tables["Image_Category"].Rows[i];
mydata = (byte[])ds.Tables[0].Rows[i]["pic"];
str[i]=new MemoryStream(mydata);
pbx[i]=new PictureBox();
pbx[i].Size = new Size(150, 150);
pbx[i].SizeMode = PictureBoxSizeMode.StretchImage;
pbx[i].BackgroundImage = Image.FromStream(str[i]);
pbx[i].Visible = true;
//this.Controls.Add(pbx[i]);
}
OR SUGGEST NEW CODE TO ME PLEASE..
Comment