SteveOOOsw
n00b
- Joined
- Dec 3, 2005
- Messages
- 19
I'm trying to add a record into an access table. I'm getting the error 'Syntax error in insert statement.' But, when I try the insert statement in access it works. Have no idea what is going on or how to fix it. Any suggestions would be much appreciated. Here is the code.
The account table has the following fields...
AccountID - pk AutoNumber
UserName - text
Password - text
EmployeeID - fk number
Code:
Public Shared Sub AddNew(ByVal aAccount As Account, ByVal aEmployee As Employee)
strUserName = aAccount.GetUserName()
strPassword = aAccount.GetPassword()
intEmployeeID = Convert.ToInt32(aEmployee.GetEmployeeID())
Dim sql As String = "INSERT INTO Account (UserName, Password, EmployeeID) VALUES ('Test', 'Test', 12)"
'"INSERT INTO Account (UserName, Password, EmployeeID) VALUES ('" & strUserName & "', '" & strPassword & "', " & intEmployeeID & ")"
Dim adpAccount As New OleDbDataAdapter()
Try
adpAccount.InsertCommand = New OleDbCommand(sql)
adpAccount.InsertCommand.Connection = aConnection
adpAccount.InsertCommand.ExecuteNonQuery()
Catch ee As OleDb.OleDbException
MessageBox.Show(ee.Message.ToString())
End Try
End Sub
The account table has the following fields...
AccountID - pk AutoNumber
UserName - text
Password - text
EmployeeID - fk number