Saving the image in SQL Server hi,
The following is the sample code to show that how we can save the image in the SQL Server. we have to take the column type as IMAGE, and using the BYTE array we can save the uploaded image.
please check the following code for this.
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]); con.Open(); byte[] ImgBytes = new byte[flurl.PostedFile.InputStream.Length]; flurl.PostedFile.InputStream.Read(ImgBytes, 0, ImgBytes.Length); string qry = "Insert into Table1(ImageData) values(@ImageData)"; SqlCommand cmd = new SqlCommand(qry, con); cmd.Parameters.AddWithValue("@ImageData", ImgBytes); cmd.ExecuteNonQuery(); con.Close();
Happy Coading!!!!!!
Thanks Anil Kumar Pandey System Architect Green Point Technology (India) Ltd. Mumbai, Maharshtra INDIA
|
No responses found. Be the first to respond and make money from revenue sharing program.
|