Hello
I have Win application used to add records into a table (called Clients) in
an Access database. I use a DataGrid1 to present records in this table and
use some TextBox(es) to display the details of a selected record.
DataGrid1.DataSource = ds 'ds is a datasource
da1.Fill(ds) 'da1 is a OleDbDataAdapter
I "Set" the content of each TextBox in the Design Properties (at DataBinding
cell) window as the following
TextBox1.setText= ds - Clients.ClientName 'set text of the TextBox1
TextBox2.setText = ds - Clients.ClientAddress
Everything works well. In the textbox1 and textbox2, I can view details of
each record in the DataGrid1
To add record, I create a button Add. When I click this button, a new record
(empty) is added at the end of the DataGrid1. Also, the TexBox1 and TexBox2
are empty. I have this code for Add button event
-----------
Me.BindingContext(ds, "Clients").AddNew()
----------
Then I have another button "Save" to save the new record into database. I
have the code for Save button event
-----------
Dim newClient As DataRow = ds.Tables("Clients").NewRow
newClient("ClientName") = TextBox1.Text
newClient("ClientAddress") = TextBox2.Text
da1.Update(ds, "Clients")
MessageBox.Show(" One record is inserted ")
------------
When I did as above, I can see some records that are added into the
DataGrid1. However only the first record is "really" saved in the database.
That means, after I close the application and open it again, I only see the
first record displayed in the DataGrid1.
Could you please help
Thank you very much
SH1