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
Is a structure a class?
What are data types with examples?
What is .cs file in c#?
Different between method overriding and method overloading?
What is this keyword in C#?
Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?
Can a static class contain non static members?
How do you prevent a class from being inherited?
What are the features of c#?
What is short in c#?
Explain get and set accessor properties?
Give 2 scenarios where static constructors can be used?
What is difference between the "throw" and "throw ex" in .net?
Who introduced c#?
How is the syntax written to inherit from a class in C#?Give an example ?