How to save image data in database?
i want to save image data in sql server 2005 what can i do?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted May 20, 2011, 10:16 PM EDT
Dinkar ChavhanRank #1,132 · 1.6K reputationPosted May 20, 2011, 11:06 PM EDT
{
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";