Previous Thread:   BackColor not gray when enabled = False

2/23/2006 9:54:50 PM    Activate Save button in BindingNavigator
I have entered a BindingNavigator toolbar in a bound form and can manage to  
  
browse records and I am able to enter data in a new record.  
  
I am ot able to save the data and therefore I have entered the save-button.  
  
How do I code this button to save a new record?  
  
reidarT



2/24/2006 4:55:16 PM    Re: Activate Save button in BindingNavigator
On Thu, 23 Feb 2006 21:54:50 +0100, "reidarT" <reidar@eivon.no> wrote:  
  
I'm new at this myself, but this may help.  
  
It depends on how your DataSet was filled.  If from a single table (no  
  
joins), a primary key exists, and none of the column names are  
  
deliniated by "[ ]" in the fill SQL statement, the 'automated'  
  
UpdateMethod should work.  
  
Assuming a dataset named MyDataSet, a bindingsource named  
  
MyBindingSoure, a tableadapter named MyTableAdapter and a table named  
  
MyTable,  this code would generally work if the above criteria are  
  
satisfied:  
  
Private Sub btnUpdate_Click(ByVal sender As Object, ByVal e As _  
  
System.EventArgs) Handles btnUpdate.Click  
  
If Me.Validate() = True Then  
  
Me.MyBindingSource.EndEdit()  
  
Me.MyTableAdapter.Update(Me.MyDataSet.MyTable)  
  
Else  
  
'there were validation errors  
  
End If  
  
End Sub  
  
In the above example, the Update statement can throw an exception if  
  
above criteria do not apply telling you that you need a valid Update  
  
Command.  I did somthing like this last week with an Access DB. At  
  
first, the update would not work.  Turned out that one of the columns  
  
in the DB was named "Size" and appeared in the SQL statement as  
  
[Size].  I renamed the column and the update then worked.  
  
Gene