Updating Database from Datagrid view (Where is problem. 1 Line of code)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • scriptick
    New Member
    • Apr 2013
    • 15

    #1

    Updating Database from Datagrid view (Where is problem. 1 Line of code)

    Hi,
    I am very tired to solve this. I know its very very very easy for beginner level programmers too.
    But i am not understanding that where is my problem.

    I just wanna update my database with one click only.

    I do for update my database from datagridview1 but it shows a error like this :

    Unhandled exception has occurred in your application . If you click Continue, the application will ignore this error and attempt to continue.
    If you click Quit,the application will close immediately.


    Update requires a valid UpdateCommand when passed DataRow
    collection with modified rows


    Thanks in advanced.
    Attached Files
  • Dan Effets
    New Member
    • Oct 2011
    • 17

    #2
    This seems to work, let me know if it works for you.
    By the way, when updating or adding new data all fields have to be filled or not null .. if one is open it will error out


    Code:
     private void btnUpdate_Click(object sender, EventArgs e)
            {
    
                this.Validate();
                this.historyBindingSource.EndEdit();
                this.historyTableAdapter.Update(this.sCHDBDataSet.History);
    
                      
    
                
    
            }

    Comment

    • scriptick
      New Member
      • Apr 2013
      • 15

      #3
      thank for your reply with code. ok I am checking it

      Comment

      Working...