Hi,
This article shows how to save image into Database SQL Server. First Create a webpage and just drag and drop FileUpload Control from toolbox
:FileUpload ID="File1" runat="server" />
Then in Button Click event Write below lines of code
int contentLength = File1.PostedFile.ContentLength;
byte[] bytePic = new byte[contentLength];
File1.PostedFile.InputStream.Read (bytePic, 0, contentLength); // File1 Is fileUpload control
SqlConnection myConn = new SqlConnection (@"server=Myserver;database=MyDB;uid=sa;pwd=sa");
try
{
connection.Open ();
SqlCommand cmd = new SqlCommand ("insert into ImageTable (pic) values (@pic)", myConn);
cmd.Parameters.Add ("@pic", BytePic);
cmd.ExecuteNonQuery ();
}
catch(Exception ex)
{
throw ex;
}
finally
{
connection.Close ();
}
Namespace used in above code are.
Using System;
Using System.Data;
Using System.Data.SqlClient;
And you are done your image is saved to Database in Table ImageTable
Cheers
Pankaj