read a lot about DataAdapter, DataTable ,.. to reach to this code, in the Save Button:
'insert new row ds.Tables('Employees').Rows.Add(ENumTxt.Text, ENameTxt.Text, EPosTxt.Text, EAgeTxt.Text, ESalTxt.Text, EPhonTxt.Text, EAdrsTxt.Text) 'save changes ds.AcceptChanges() Try If ds.HasChanges Then Dim AffectedDS As DataSet = ds.GetChanges(DataRowState.Added) 'im ComBuilder As New OleDb.OleDbCommandBuilder(da) da.InsertCommand = ComBuilder.GetInsertCommand da.Update(AffectedDS, 'Employees') End If Catch e1 As OleDb.OleDbException MessageBox.Show(e1.Message) End Try
=============================================================================== Then I tried this:
Dim cb As New OleDb.OleDbCommandBuilder(da) ' Insert a new record in the DataSet Dim r As DataRow = ds.Tables('Employees').NewRow() r('EID') = ENumTxt.Text r('EName') = ENameTxt.Text r('Age') = EAgeTxt.Text r('Salary') = ESalTxt.Text r('EPhone') = EPhonTxt.Text r('EAddress') = EAdrsTxt.Text ds.Tables('Employees').Rows.Add(r) ' Insert the record even in the database da.Update(ds.Tables('Employees').GetChanges()) ' Align in-memory data with the data source ones ds.AcceptChanges()
==========
In run time, i got the same error message for both cases
'Syntax error in INSERT INTO statement'
Please give me some guidlines to fix this error.
Ther error is in your INSERT statement, as the error says …
How does the INSERT statement that has been specified by the ‘InsertCommand’ of your DataAdapter look like ?