Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 Help Members By Posting Answers For Below Questions

What's difference between constants and static readonly?

1193


If the interface in c# only contains the declaration of the methods and we need to define those methods in the class, then why we use the interface?

1012


What is an interface class? Give one example of it

910


What is task parallel library?

1046


What is interface inheritance?

955


What is view model in c#?

851


What Is The Difference Between The System.array.copyto() And System.array.clone()?

1022


What are the variables in c#?

946


What does clr stand for?

919


What is the differences between datagrid, datalist and repeater in .net?

998


What is a race condition?

903


What is difference between continue and break in c#?

963


What is data adapter in c#?

883


Is arraylist thread safe?

883


What is Covariance and contravariance in C#?

1064