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 .net and c# the same?
Explain the difference between abstract class and interface.
Can we write class inside a class in c#?
Can we inherit partial class in c#?
What are the 3 elements of delegation?
Is enum a value type c#?
What is meant by desktop application?
Explain why do I get an error (cs1006) when trying to declare a method without specifying a return type?
Distinguish between a class and struct?
What is collection class c#?
Why is c# better than java?
Why is hashset faster?
what is difference between is and as operators in c#?
What is a clr (common language runtime)?
What is the use of console readkey in c#?