Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SqlConnection cnn = new SqlConnection(@"Data Source=DANNY-PC\SQLEXPRESS;Initial Catalog=coba;Integrated Security=True;Pooling=False");
                byte[] imgData = File.ReadAllBytes(pictureBox1.ImageLocation);
                MessageBox.Show(Convert.ToString(imgData)); // How to display image data in message box?
                int varID = Convert.ToInt16(textBox1.Text);
                string varNama = textBox2.Text;
                SqlCommand cmd = new SqlCommand("INSERT INTO Table2 (ID,Nama,Foto) VALUES (@ID,@Nama,@Foto)", cnn);
                cmd.Parameters.Add("@ID", varID);
                cmd.Parameters.Add("@Nama", varNama);
                cmd.Parameters.Add("@Foto", imgData);
                cnn.Open();
                cmd.ExecuteNonQuery();
                cnn.Close();


[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 22-Aug-14 5:58am
v2
Comments
OriginalGriff 22-Aug-14 11:59am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.

1 solution

Firstly, This is not a sensible question.
There are tools present in this forum to allow for formatting and you shouldn't just dump code into the question box. You should format it and then describe what you are trying to achieve and what your issue is clearly.

Secondly,

I believe you would need to create your own form to act as a "message box" in order to display your image. The MessageBox in the .Net framework in my experience expects strings to be passed and does not expect to have to display any images.

If you create a form, you can use the options to configure it to be a bit like a message box but that will up to you.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Aug-14 12:12pm    
Agree, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900