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
What's difference between constants and static readonly?
If the interface in c# only contains the declaration of the methods and we need to define those methods in the class, then why we use the interface?
What is an interface class? Give one example of it
What is task parallel library?
What is interface inheritance?
What is view model in c#?
What Is The Difference Between The System.array.copyto() And System.array.clone()?
What are the variables in c#?
What does clr stand for?
What is the differences between datagrid, datalist and repeater in .net?
What is a race condition?
What is difference between continue and break in c#?
What is data adapter in c#?
Is arraylist thread safe?
What is Covariance and contravariance in C#?