Click here to Skip to main content
11,495,656 members (61,098 online)
Rate this: bad
good
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() + "";
        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 28-Nov-12 21:28pm
Edited 28-Nov-12 21:33pm
__TR__29K
v2
Comments
__TR__ at 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
good
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!
  Permalink  
Comments
__TR__ at 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
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 275
3 Nakul Chaudhari 236
4 Sergey Alexandrovich Kryukov 230
0 Sergey Alexandrovich Kryukov 10,362
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2015
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