protected void GVImages_RowUpdating(object sender, GridViewUpdateEventArgs e) { string ID = ((Label)GVImages.Rows[e.RowIndex].FindControl("lblID")).Text; string Name = ((TextBox)GVImages.Rows[e.RowIndex].FindControl("txtName")).Text; FileUpload f = ((FileUpload)GVImages.Rows[e.RowIndex].FindControl("FileUpload2")); byte[] imageBytes = null; if (f.HasFile) { //variable to store the image content imageBytes = new byte[f.PostedFile.ContentLength]; HttpPostedFile uploadImage = f.PostedFile; //read the image stream from the post and store it in imageBytes uploadImage.InputStream.Read(imageBytes, 0, (int)f.PostedFile.ContentLength); } con.Open(); MySqlCommand cmd = new MySqlCommand("Update images set Name=@Name,Content=@Content where ID="+ID, con); cmd.Parameters.Add("@ID", MySqlDbType.Int16).Value = ID; cmd.Parameters.Add("@Name", MySqlDbType.VarChar).Value= Name; cmd.Parameters.Add("@Content", MySqlDbType.LongBlob).Value = imageBytes; cmd.Connection = con; cmd.ExecuteNonQuery(); GVImages.EditIndex = -1; con.Close(); databind(); }
MySqlCommand cmd = new MySqlCommand(" Update images set Name=@Name,Content=@Content where ID=" +ID, con);
MySqlCommand cmd = new MySqlCommand(" Update images set Name=@Name,Content=@Content where ID=@ID", con);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)