Insert statement error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I have the following problem that I can't seem to solve.

I have a database with 6 different tables. when I update the tables I have
no problems expect with 1 table.
I get a "the instruction Insert contains a syntax error" (I translated this
to english cause I get the error message in dutch).
Using the debugger I can only find the following info
" cannot view the index property " (this not translated).

Most of my other tables have the same layout but they don't give me any
problems. I would like to know how I can find out more on this error.

Extra info:
I use Access database (mdb file)
- I use OleDbcommand, OleDbBuilder and the OleDbAdapter.
The table has no primary key but is linked to another table that has a
primary key.

I hope someone can give me some background info on insert commands and
errors related to these commands.

Bardo
 
get the OleDbcommand.CommandText variable contents just before you try and
insert it. Then try and run the query directly in Access. Access will give
you more help on what's wrong. I do this in SQL Analyzer all the time to
fix my statements.

Chris
 
Bardo,

If the table has no primary key, then when updating, it is probably
doing a comparison on every field in the table to determine which record is
being updated. This can lead to some very large queries being generated for
your table. I would recommend taking a look at the update and delete
commands for the table, and possibly adding a primary key for that table,
and see if it works.

Hope this helps.
 
Maybe your sql string contains a string to insert to the table with signs
that Access thinks it is part of the command such as "."
If you have such a sign put ' before and after.
"cannot view the index property" is ok. The debugger says it can't show you
a collection. If this collection count is more than zero, then you can view
some items of it by giving a key or an index in the debugger like
"collection[0]".
 
Chris , Nicholas Paldino, Amiram Korach

I solved the problem. One of the columns was named "From" this column gave a
error. Because its a reserved word in the access database structure.
I want to thank you three for the input.

Bardo
 
Back
Top