Click here to Skip to main content
15,885,899 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
protected void ResultGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
  TextBox txtFName = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtFName");
        TextBox txtLName = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtLName");
        TextBox txtCity = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtCity");
        TextBox txtState = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtState");
        TextBox txtCountry = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtCountry");
        TextBox txtDescription = (TextBox)ResultGridView.Rows[e.RowIndex].FindControl("txtDescription");
 
 cmd.Connection = con;
 cmd.CommandText = "Update Vendors Set VendorFName = '" + txtFName.Text + "',VendorLName = '" + txtLName.Text + "',VendorCity = '" + txtCity.Text + "',VendorState = '" + txtState.Text + "',VendorCountry = '" + txtCountry.Text + "',VendorDescription = '" + txtDescription.Text + "' where VendorId = " + ResultGridView.DataKeys[e.RowIndex].Values[0].ToString() + "";
        con.Open();
        cmd.ExecuteNonQuery();
        ResultGridView.EditIndex = -1;
        FillVendorGrid();
        con.Close();


From the above what is the error please correct it.

i send the code.please correct from my code
Posted
Updated 28-Nov-12 20:33pm
v2
Comments
__TR__ 29-Nov-12 2:35am    
Did you debug your code ? What is the error message you are getting and in which line is the error occurring ?

1 solution

You are supposed to tell us what the error is. We do not have your application nor do we have your database. A couple of things you can do!

Check that the text fields all have enclosing single quotes.
Debug the app and capture the Command.Text and try and run it in SSMS to find the error.

Learn about paramterised queries.
Learn about SQL Injection.

Meet my mate Bobby Tables!
 
Share this answer
 
Comments
__TR__ 29-Nov-12 2:44am    
My 5.
Just in case if the OP is wondering Who is bobby tables ?[^]

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