Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear All,

update image using asp.net:

Source code:

C#
protected void Button1_Click1(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString);
        string strimage = @"~\ProductImages\" + FileUpload1.FileName;
        FileUpload1.PostedFile.SaveAs(Server.MapPath(strimage));
        String strInsert = "update SubmitTable set Photo=@Photo where EmailAddress=@EmailAddress";
        SqlCommand cmd = new SqlCommand(strInsert, con);

        SqlParameter Photo = new SqlParameter("@Photo", SqlDbType.NVarChar);
        Photo.Value = FileUpload1.FileBytes.ToString();
        cmd.Parameters.Add(Photo);

        SqlParameter EmailAddress = new SqlParameter("@EmailAddress", SqlDbType.NVarChar);
        EmailAddress.Value = Label1.Text.ToString();
        cmd.Parameters.Add(EmailAddress);

        try
        {
            con.Open();
            cmd.ExecuteNonQuery();
            
        }
        catch (SqlException ex)
        {

        }
        finally
        {
            con.Close();
        }
        Response.Redirect("Update.aspx");
    }


here image not update please reply me what mistake here and any examples
Posted
Updated 31-Jul-14 21:20pm
v3
Comments
Nirav Prabtani 31-Jul-14 1:21am    
Where have you used stored procedure????
member1431 31-Jul-14 1:38am    
actually this table name is submittable
and this table stored procedure name is:sp_submittable

stored procedure i used starting index page
Nirav Prabtani 31-Jul-14 1:54am    
Nopp, you have not used Stored Procedure..!!
member1431 31-Jul-14 2:00am    
ok and here what mistake please reply me

here image not uploaded
Nirav Prabtani 31-Jul-14 2:04am    
Refer all links in my 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