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
How do you concatenate in c#?
Explain the difference between proc. Sent by val and by sub?
What is an escape sequence in c#?
Enlist all the components of an ado.net framework?
Differentiate between static class and singleton instance?
State whether it is true to test a Web service you must create a windows application or Web application to consume this service or not?
Is c sharp free?
List some of the classes used by system.data namespace?
What are the different types of comments in c#?
Is functional interface runnable?
Which string method is used for concatenation of two strings in c#?
What is xor operation?
What are the different types of assemblies available and their purpose?
Is string value type c#?
Explain About disco and uddi