Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Microsoft Access and VB.NET Help
I need some assistance with Microsoft Access and Visual Basic.NET.
I'm trying to insert records into a database but keep getting a 'INSERT INTO syntax error'. Here's the code snippit:
Dim Con As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=./ds/dsstore.mdb;Jet OLEDB:Database Password=password;")
Dim Com As OleDb.OleDbCommand = New OleDb.OleDbCommand("INSERT INTO useraccess(FirstName,Surname,IDNumber,UserState,UserLevel,Username,Password) VALUES('" & txtFirstName.Text & "','" & txtSurname.Text & "'," & txtIDNumber.Text & ",'" & cboUserState.Text & "','" & cboUserLevel.Text & "','" & txtUsername.Text & "','" & txtConfirmPassword.Text & "')", Con)
frmMain.tsStatus.Text = "Waiting..."
Catch ex As Exception
notifyUAC.BalloonTipIcon = ToolTipIcon.Error
notifyUAC.BalloonTipTitle = ex.Source
notifyUAC.BalloonTipText = ex.Message
frmMain.tsStatus.Text = "System Ready"
In the database I've got the fields listed above but it also includes a primary key field labeled 'UACNumber' which is set to AutoNumber in Access.
Currently using VB 2008 and Access 2007 (DB in 2000 format).