Skip to content

Gridview Updating Problem

Henrik Mikkelsen

Asked Mar 19, 2013, 1:45 PM EDT1 answer
Share
LinkedInX
Heey all, im having a little problem with my gridveiw updating command, i have tryed almost every thing knownen to me

all it have to do is update text and "imagepath and imagename"

and i have chected the spelling of the database names 

Hope someone can help me


C#
string connection = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
                SqlConnection conn = new SqlConnection(connection);






                SqlCommand mySqlUpdate = new SqlCommand("UPDATE sv_Employee SET EmployeeName = @EmployeeName, EmployeeImage = @EmployeeImage WHERE EmployeeID = @EmployeeID", conn);


                mySqlUpdate.CommandType = CommandType.Text;


                mySqlUpdate.Parameters.Add("@EmployeeID", SqlDbType.Int).Value = Convert.ToInt32(lblEmployeeID.Text);
                mySqlUpdate.Parameters.Add("@EmployeeName", SqlDbType.NVarChar).Value = txtEmployeeName.Text;
                mySqlUpdate.Parameters.AddWithValue("@EmployeeImage", (imgPicture.ImageUrl == null ? (object)DBNull.Value : (object)imgPicture.ImageUrl));


                try
                {
                    conn.Open();
                    mySqlUpdate.ExecuteNonQuery();
                }
                finally
                {
                    conn.Close();
                }

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.