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 the different types of classes?
What is an event in c#?
write a C# Program add two matrix ?
Why abstract class is not instantiated in c#?
What is strongly typed in c#?
What is default constructor in c#?
What is the difference between finalize() and dispose()?
What are assemblies?
What is indexer c#?
Can properties be static in c#?
Can a child class call the constructor of a base class?
What is a factory in c#?
What are the types of comment in c# with examples?
Why do you call it a process? What’s different between process and application in .net, not common computer usage, terminology?
Why reflection is used in c#?