Versaiteis
Member
- Joined
- Mar 12, 2010
- Messages
- 14
- Programming Experience
- 1-3
Alright, so I keep getting this error every time I try to add a record to an access database. I've checked all of my columns and everything I could think of but I do not believe any of them are reserved by access.
What I'm asking is either what exactly is the problem here and/or how do I view the INSERT INTO statement. The error occurs during run time. When the program crashes it says "OleDBException was unhandled" and the syntax error above.
What's weird about this is that I have another database in the bin folder and if I change
to
The whole program works absolutely fine. I am able to add the new record to the AddressBook database, but to change it to the FWDatabase database throws the same error everytime =\
Here is the code:
What I'm asking is either what exactly is the problem here and/or how do I view the INSERT INTO statement. The error occurs during run time. When the program crashes it says "OleDBException was unhandled" and the syntax error above.
What's weird about this is that I have another database in the bin folder and if I change
VB.NET:
Data source= FWDatabase.mdb
to
VB.NET:
Data source= AddressBook.mdb
The whole program works absolutely fine. I am able to add the new record to the AddressBook database, but to change it to the FWDatabase database throws the same error everytime =\
Here is the code:
VB.NET:
Public Class Form1
Dim inc As Integer
Dim MaxRows As Integer
Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "[PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = FWDatabase.mdb]"
con.Open()
sql = "SELECT * FROM tblClients"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "AddressBook")
con.Close()
MaxRows = ds.Tables("AddressBook").Rows.Count
inc = 0
NavigateRecords()
End Sub
Private Sub btnCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCommit.Click
If inc <> -1 Then
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("AddressBook").NewRow()
dsNewRow.Item(1) = txtFirstName.Text
dsNewRow.Item(2) = Date.Now
ds.Tables("AddressBook").Rows.Add(dsNewRow)
da.Update(ds, "AddressBook")
MsgBox("New Record added to Database")
btnCommit.Enabled = False
btnAddNew.Enabled = True
btnUpdate.Enabled = True
btnDelete.Enabled = True
End If
End Sub
End Class