Fail update database from DataGridView
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Fail update database from DataGridView

  1. #1
    Join Date
    Oct 2006

    Question Fail update database from DataGridView

    I am working at winforms project and i have a datagridview from which i am trying to update a database from it when the user changes something. Here is the code:

    DataSet ds = new DataSet();
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["EbosPr.Properties.Settings.Database1ConnectionString1"].ConnectionString);
    SqlCommand scmd = new SqlCommand("Select * From CustCalls ", conn);
    SqlDataAdapter sda = new SqlDataAdapter(scmd);


    DataTable dt = ds.Tables[0];
    SqlCommandBuilder myBuilder = new SqlCommandBuilder(sda);


    sda.UpdateCommand = myBuilder.GetUpdateCommand();

    The above code doesnt update the database. Any idea?

  2. #2
    Join Date
    Dec 2011

    Re: Fail update database from DataGridView

    Did you check the below?

    Before to your Update command ou have to give


    And after to your update command you have to give

    Last edited by MAHEY; February 17th, 2012 at 12:39 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)