Can anyone assist with the Adding Records Issue.[Resolved]
I am tying to add a datarow to an access database.
Here is the code
Try
InvoiceConnection = New OleDb.OleDbConnection
InvoiceConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\InvoiceData.mdb"
UserCommand = New OleDb.OleDbCommand(sSQLString)
UserAdapter = New OleDb.OleDbDataAdapter(UserCommand)
UserCommand.Connection = InvoiceConnection
InvoiceConnection.Open()
UserCommand.ExecuteNonQuery()
UserAdapter.FillSchema(dsUser, SchemaType.Source)
UserAdapter.Fill(dsUser, "UserInfo")
Try
Dim autonumber As Short = 0
Dim drUserRow as New Datarow
drUserRow = dsUser.Tables("UserInfo").NewRow()
drUserRow.Item(0) = autonumber
drUserRow.Item(1) = txtUserName.Text
drUserRow.Item(2) = txtPassword.Text
drUserRow.Item(3) = txtFullName.Text
drUserRow.Item(4) = txtAddress1.Text
drUserRow.Item(5) = txtAddress2.Text
drUserRow.Item(6) = txtCity.Text
drUserRow.Item(7) = cboState.Text
drUserRow.Item(8) = txtZipCode.Text
drUserRow.Item(9) = txtPhoneNumber.Text
Dim userbuilder As New OleDb.OleDbCommandBuilder(UserAdapter)
UserAdapter = userbuilder.DataAdapter
dsUser.Tables("UserInfo").Rows.Add(drUserRow)
UserAdapter.Update(dsUser, "UserInfo")
Catch ex As Exception
Call MessageBox.Show(ex.Message & " Occured In: " & ex.Source, "Error Adding Record", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
InvoiceConnection.Close()
I am getting an error message on The Line:
UserAdapter.Update(dsUser, "UserInfo")
It says "Syntax Error in INSERT INTO Statement"
I am not sure why this is not working. I have pretty much gone by Pirate's Example.
It adds to the dataset fine. Just will not add it to the table.
any help would be appreciated
Thanks in Advance