TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raj mca
NA
3
1.7k
How to display multiple images from sql server 2005 into c#
Mar 27 2013 12:13 AM
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...
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]);
}
PLEASE TELL IS IT ANY WRONG WITH THIS CODE?
OR SUGGEST NEW CODE TO ME PLEASE..
its very urgent
Reply
Answers (
0
)
Load Items Of ComboBox into DataGridViewComboBoxColumn
Use bool variable