Hi all,
In the program I'm working on, I am making a form that submits data to an Access 2007 database. I can connect to the database fine and run a select query, but when I try an insert query I get an error: "statement contains the following unknown field name: 'Last_Name' (see details below). This error occurs at my ExecuteReader command. The field is present in my table, and I've double checked for extra spaces and the like. Any ideas what could be causing this error?
The relevent code is:
Dim custstr As String = "INSERT INTO [Customer] ([Company], [Last_Name], [First_Name], [Business_Phone]," & _
" [Home_Phone], [Mobile_Phone], [Fax], [Email]) SELECT '" & txt_company.Text.ToString & _
"', '" & txt_lastname.Text.ToString & "', '" & txt_firstname.Text.ToString & "', '" & _
txt_busphone.Text.ToString & "', '" & txt_homephone.Text.ToString & "', '" & _
txt_mobilephone.Text.ToString & "', '" & txt_fax.Text.ToString & "', '" & txt_email.Text.ToString & "'"
MsgBox("Company: " & txt_company.Text & " Last_Name: " & txt_lastname.Text)
cmd = New OleDbCommand(custstr, con)
rdr = cmd.ExecuteReader() 'error points here
If Not (rdr.Read()) Then
MsgBox("Could not insert record into database, please try again or contact system admin.\n\n",
MsgBoxStyle.OkOnly, "Error:\n\n")
End If
Error message and Customer table: