Haven't been able to figure out what the problem is. I'm just trying to add the following to an Access DB. It's probably very simple but I've tried everything! Error reads - Syntax error in INSERT INTO statement. It points to the "da.Update(ds, "Tasks")" line. The objRows are accepting the values passed to them.
Private Sub btnAddTaskSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddTaskSave.Click
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = E:\college\database.mdb"
con.Open()
sql = "SELECT CustomerID, Description, Date, EmpID, InvoiceID FROM Tasks"
da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.Fill(ds, "Tasks")
Dim objRow As DataRow
'Create a new DataRow object for this table
'Create a new DataRow object for this table
objRow = ds.Tables("Tasks").NewRow
objRow("CustomerID") = lblAddTaskFName.Text
objRow("Description") = txtAddTaskDescription.Text
objRow("Date") = dtpAddTask.Value
objRow("EmpID") = 2 'cboAddTaskEmployee.SelectedItem
objRow("InvoiceID") = 4
'Officically add the Datarow to table
ds.Tables("Tasks").Rows.Add(objRow)
da.Update(ds, "Tasks")
con.Close()
MsgBox("New Task Added")
End Sub
Many thanks
Private Sub btnAddTaskSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddTaskSave.Click
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = E:\college\database.mdb"
con.Open()
sql = "SELECT CustomerID, Description, Date, EmpID, InvoiceID FROM Tasks"
da = New OleDb.OleDbDataAdapter(sql, con)
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.Fill(ds, "Tasks")
Dim objRow As DataRow
'Create a new DataRow object for this table
'Create a new DataRow object for this table
objRow = ds.Tables("Tasks").NewRow
objRow("CustomerID") = lblAddTaskFName.Text
objRow("Description") = txtAddTaskDescription.Text
objRow("Date") = dtpAddTask.Value
objRow("EmpID") = 2 'cboAddTaskEmployee.SelectedItem
objRow("InvoiceID") = 4
'Officically add the Datarow to table
ds.Tables("Tasks").Rows.Add(objRow)
da.Update(ds, "Tasks")
con.Close()
MsgBox("New Task Added")
End Sub
Many thanks