473,566 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
4 1319
get the OleDbcommand.Co mmandText 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***@discussi ons.microsoft.c om> wrote in message
news:9F******** *************** ***********@mic rosoft.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.co m

"bardo" <ba***@discussi ons.microsoft.c om> wrote in message
news:9F******** *************** ***********@mic rosoft.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
16984
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums must be UPDATED, if not, they must be INSERTED. Logically then, I would like to SELECT * FROM <TABLE> WHERE ....<Values entered here>, and then...
6
4678
by: harborboy76 | last post by:
Hi, I am trying to insert a large number of rows into a table inside a SPL. But every time, I run the SPL, the table is locked because of the INSERT. When I tried to issue a COMMIT, right after the INSERT in the SPL. I got an error stating that there was no open cursor. I have done some research on here and found that it's not possible to...
7
6652
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks!
17
683
by: kosta | last post by:
hello! one of my forms communicates with a database, and is supposed to add a row to a table using an Insert statement... however, I get a 'oledb - syntax error' exception... I have double checked, and the insert works fine (tried to use it from access)... im using visual C# express 2k5... what could be wrong? thanks! it is an access...
6
3445
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am using MS-Access 2000 database table for this app. Note that the datatype of all the fields mentioned above are Text. Apart from the above columns,...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.