Click here to Skip to main content
12,755,775 members (35,808 online)
Rate this:
Please Sign up or sign in to vote.
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() + "";
        ResultGridView.EditIndex = -1;

From the above what is the error please correct it.

i send the code.please correct from my code
Posted 28-Nov-12 21:28pm
Updated 28-Nov-12 21:33pm
__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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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!
__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)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170217.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100