How to store image file in Sql server database?
Answer Posted / y.s.a.naidu
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms,
pictureBox1.Image.RawFormat);
byte[] img = ms.GetBuffer();
SqlCommand cmd = new SqlCommand("Insert into
tbl_Image(Images) values(@imgs)", cn);
SqlParameter p1 = new SqlParameter();
p1.ParameterName = "@imgs";
p1.SqlDbType = SqlDbType.Image;
p1.Value = img;
cmd.Parameters.Add(p1);
cn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Image Inserted ....");
cn.Close();
| Is This Answer Correct ? | 1 Yes | 3 No |
Post New Answer View All Answers
Define collections?
What are the desktop applications?
What is difference between ienumerable and list in c#?
What does public mean in c#?
Which attribute is used in order that the method can be used as webservice?
What can be done with c#?
Can we declare private class in c#?
How do you escape a character?
What is the difference between a constant and a static readonly field?
Name which controls do not have events?
What is the difference between a function and a method?
Is c# easier than c++?
What are managed providers?
Why constructor is used in c#?
Why to use “using” in c#?