I am trying to add new rows to MyDataBase.mdb with the below code. My problem is that it does not identify the columns. It fails with the error message ¡°Name1 does not belong to Customers¡±. But it does so do Name2. I think it¡¯s locating the database and table as I can retrieve data with the open code using SQL Select.
Can anyone help Please
hemo
Dim connection As New OleDbConnection()
Dim myadapter As OleDbDataAdapter
Dim myDataSet As New DataSet
Dim newrow As DataRow
Dim MyTable As DataTable
connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Projects2005\MyDataBase.mdb"
myadapter = New OleDbDataAdapter("Customers", connection)
MyTable = New DataTable("Customers")
connection.Open()
newrow = MyTable.NewRow()
newrow("Name1") = TextBox1
newrow("Name3") = TextBox2
MyTable.Rows.Add(newrow)
myadapter.Update(myTable)
connection.Close()