Click here to Skip to main content
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__28.9K
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 Marcin Kozub 310
1 OriginalGriff 248
2 Sergey Alexandrovich Kryukov 215
3 Richard MacCutchan 202
4 Praneet Nadkar 197
0 OriginalGriff 8,048
1 Sergey Alexandrovich Kryukov 7,287
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,910


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
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