As the title states, I am having a problem and I cannot find it's cause.
Imports System
Imports System.Data.OleDb
Public Class Register
Dim con As New OleDbConnection
Dim strProvider As String
Dim strDataSource As String
Dim tables As DataTableCollection
Dim source1 As New BindingSource
Dim strSQL As String
Dim dt As New DataTable
Dim ds As New DataSet
Dim da As New OleDbDataAdapter
Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
Me.Close()
SRS_Main_Menu.Show()
End Sub
Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
strDataSource = "Data Source = C:\Users\WORK\Documents\vb.net db files\questionThreeDB1.mdb"
strProvider = "PROVIDER= Microsoft.JET.OLEDB.4.0;"
con.ConnectionString = strProvider & strDataSource
tables = ds.Tables
strSQL = "SELECT * FROM questionThreeTbl"
da = New OleDbDataAdapter(strSQL, con)
da.Fill(ds, "Students")
Dim cb As New OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Students").NewRow()
dsNewRow.Item(1) = txtId.Text()
dsNewRow.Item(2) = txtName.Text()
dsNewRow.Item(3) = txtSurname.Text()
dsNewRow.Item(4) = txtCellNum.Text()
dsNewRow.Item(5) = txtParCell.Text()
dsNewRow.Item(6) = txtAddress.Text()
ds.Tables("Students").Rows.Add(dsNewRow)
da.Update(ds, "Students")
MsgBox("New Student Record Saved")
Me.Close()
SRS_Main_Menu.Show()
End Sub
End Class
Basically when I select the submit button the error pops up pointing to the line:
da.Update(ds, "Students")
It states that there is a problem with my INSERT INTO statement. Any clues as to what is going on here?