467,081 Members | 968 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,081 developers. It's quick & easy.

Insert statement error

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
Nov 16 '05 #1
  • viewed: 1134
Share:
4 Replies
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" <ba***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
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

Nov 16 '05 #2
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"bardo" <ba***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
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

Nov 16 '05 #3
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]".

"bardo" wrote:
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

Nov 16 '05 #4
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
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by Philip Boonzaaier | last post: by
6 posts views Thread by harborboy76@yahoo.com | last post: by
6 posts views Thread by rn5a@rediffmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.