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 is use of hashtable in c#?
What is the use of protected in c#?
What is a hash table c#?
Can you access a hidden base class method in the derived class?
How is the syntax written to inherit from a class in C#?Give an example ?
What is the use of base keyword? Tell me a practical example for base keyword’s usage?
What is Inheritance in C#?
What are the differences between a class and a struct?
Explain about generics in c#.net?
How Do You Convert A Value-type To A Reference-type?
Does c# have its own class library?
What is the difference between returning iqueryable vs ienumerable?
How can we set the class to be inherited, but prevent the method from being over-ridden?
what is the scope of anonymous type ?
What is lock in c#?