When my code runs it evaluated this code and returns a result from my textbox like this:
"INSERT INTO tblPositions (Position, EmailAddress) VALUES ('ki','')"
When it runs, it goes through my common database execute function I use everywhere (which works fone on other pages that are almost identical). I am getting the error "Syntax error in INSERT INTO statement." In the oledberror errors collection, it says "In
order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user".
I am at my wits end. It is almost identical to another page I have and the other page works. Just a few different text boxes and a different table. All fields not updated are autonumber or have default values like all the other tables I insert into.
I created a whole new table with just an autonumber ID field and a "Position" column that was text. I ran the same line of code as above except I took out the email address and the last set of quotes in the values as well as changed the table name. Still
got the same error.
sql = "INSERT INTO tblNewP (Position) VALUES ('test')"
I have tried hardcoding the values adn not using the textbox. I just cannot figure out why this one insert is not working. I know it is going to be a simple thing to and I just cannot see it.
In Jet, Position is a Reserved word. Reserved words should better not be used as field (or table) names, but if you do, you need to enclose the fieldname with brackets
INSERT INTO tblPositions ([Position], EmailAddress) VALUES ('ki','')
makakaneohe
Member
1 Points
6 Posts
Error on Insert into Access Database
May 25, 2012 06:54 PM|LINK
my SQL statement is coded as such:
sql = "INSERT INTO tblPositions (Position, EmailAddress) VALUES ('" & txtNewPosition.Text & "','')"When my code runs it evaluated this code and returns a result from my textbox like this:
"INSERT INTO tblPositions (Position, EmailAddress) VALUES ('ki','')"When it runs, it goes through my common database execute function I use everywhere (which works fone on other pages that are almost identical). I am getting the error "Syntax error in INSERT INTO statement." In the oledberror errors collection, it says "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user".
I am at my wits end. It is almost identical to another page I have and the other page works. Just a few different text boxes and a different table. All fields not updated are autonumber or have default values like all the other tables I insert into.
Thanks
makakaneohe
Member
1 Points
6 Posts
Re: Error on Insert into Access Database
May 25, 2012 07:49 PM|LINK
I created a whole new table with just an autonumber ID field and a "Position" column that was text. I ran the same line of code as above except I took out the email address and the last set of quotes in the values as well as changed the table name. Still got the same error.
sql = "INSERT INTO tblNewP (Position) VALUES ('test')"I have tried hardcoding the values adn not using the textbox. I just cannot figure out why this one insert is not working. I know it is going to be a simple thing to and I just cannot see it.
hans_v
All-Star
35986 Points
6550 Posts
Re: Error on Insert into Access Database
May 25, 2012 09:42 PM|LINK
In Jet, Position is a Reserved word. Reserved words should better not be used as field (or table) names, but if you do, you need to enclose the fieldname with brackets
INSERT INTO tblPositions ([Position], EmailAddress) VALUES ('ki','')
http://support.microsoft.com/kb/321266
By the way
You better read this
http://www.mikesdotnetting.com/Article/26/Parameter-Queries-in-ASP.NET-with-MS-Access