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
Please explain the basic string operations used in c#?
What are the collections in c#?
Explain the difference between object type and dynamic type variables in c#?
How long does a loop recorder procedure take?
Can we create multiple constructors?
How many types of methods are there in c#?
Can we override constructor in c#?
What is the difference between const and static read-only?
What is an array of arrays called?
What is the difference between func and action delegate?
Are arrays value types or reference types?
What is foreach loop in c#?
How do you encapsulate in c#?
Why is c# used?
How can I use .NET components from COM programs?