how to save image data in database?
i want to save image data in sql server 2005 what can i do?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dinkar ChavhanPosted May 21, 2011, 3:06 AM
{
string img = FileUpload1.FileName.ToString();
SqlConnection con1 = new SqlConnection("Data Source=shashi-pc;Initial Catalog=offer;User ID=sa;Password=omsairam");
SqlCommand cmd1 = new SqlCommand();
cmd1.Connection = con1;
con1.Open();
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.CommandText = "SP_insertImage";
cmd1.Parameters.AddWithValue("@image","~/images/"+img);
int i = cmd1.ExecuteNonQuery();
con1.Close();
if (i > 0)
{
Label1.Text = "posted successful";
FileUpload1.PostedFile.SaveAs(MapPath("~/images/" + img));
}
else
Label1.Text = "pls fill correct";
Krishna GaradPosted May 21, 2011, 2:16 AM