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
You are creating a custom usercontrol, some of the newly created properties are shown in the properties window. How you can hide a new property named theme from the properties window?
What are "class access modifiers" in C#?
Can a class have multiple constructors c#?
Explain what a diffgram, and a good use for one Define diffgram? How it be used?
What is interpolation in programming?
What is a console device?
What is the difference between disposing of () and finalize() methods in c#?
Define a manifest in .net?
How to override a function in c#?
What is reflection in c#?
Explain About stateless and state full web service
How many types of constructors are there in c#?
How can I develop an application that automatically updates itself from the web?
What are the Types of configuration files and their differences
How many parameters can a method have c#?