Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code to insert empno,empname,IMAGE with store procedure name "emp_insert"
Please Help me
C#
protected void btnSave_Click(object sender, EventArgs e)
   {
       con.Open();
       cmd = new SqlCommand("emp_insert", con);
       cmd.CommandType = CommandType.StoredProcedure;
       cmd.Parameters.AddWithValue("@empno", TextBox1.Text);
       cmd.Parameters.AddWithValue("@empname", TextBox2.Text);
       cmd.Parameters.AddWithValue("@Picture", FileUpload1.FileName);
       cmd.Parameters.AddWithValue("@action", "i");
       cmd.ExecuteNonQuery();
       Label3.Text = "Inserted";
       con.Close();
   }
Posted
Updated 11-Aug-18 2:27am
v3

try as follows :
C#
cmd.CommandType = CommandType.StoredProcedure;



SqlParameter[] prms = new SqlParameter[3];

prms[0] = new SqlParameter("@fileName", SqlDbType.VarChar, 50);

prms[0].Value = fileName;

prms[1] = new SqlParameter("@fileContent", SqlDbType.Image);

prms[1].Value = imageBytes;

prms[2] = new SqlParameter("@active", SqlDbType.Bit);

prms[2].Value = true; // hard coded value


cmd.Parameters.AddRange(prms);



conn.Open();

cmd.ExecuteNonQuery();

conn.Close();





for more refer:http://www.dotnetfunda.com/articles/article1546-how-to-save-an-image-into-the-database-using-stored-procedure-in-aspnet-.aspx[^]
 
Share this answer
 
v3
i think you should directly put images in your database with image datatype, and then retrive it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900