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 are collections in c#?
What is a helper method in c#?
How can we sort the elements of the array in descending order?
What is this keyword in C#?
How does a while loop work?
How does array sort work?
Which namespaces are necessary to create a localized application?
Please write a program to display “welcome to bestinterviewquestion.com” in c#?
Why generics are used in c#?
Are string objects mutable or immutable?
What is the difference between proc. Sent by val and by sub?
What does question mark mean in c#?
What is hashmap in c#?
What is the difference between list and array in c#?
Are structs value types or reference types?