473,382 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Syntax error in insert statement

Hi all!!

I need your help.... i'm working since 2 hours on a simple insert statement,
but couldn't handle it.

Here is my code :

public int ExecQuery(string SqlString)

{
OleDbConnection oCoon = new OleDbConnection(connectionString);

oCoon.Open();

OleDbCommand cmd3 = new OleDbCommand();

cmd3.Connection = oCoon;

cmd3.CommandText = SqlString;

if(oCoon.State == ConnectionState.Closed)

{

oCoon.Open();

}

cmd3.ExecuteNonQuery();

return 1

}

When the code reach the cmd3.ExecuteNonQuery(); I always receive the
followin error :

SYNTAX ERROR IN INSERT INTO STATEMENT....

But, i tried to put some debug info (Debug.Write) and my SQL statement seem
ok.

SQL Statement : INSERT INTO COLORS (agent_no,primary,secondary) VALUES
(3,'fff','ALLO')

Any idea??

Thanks,
Nov 18 '05 #1
2 1581
primary is a reserved word. Put this instead [primary]

"eric dugal" <er********@videotron.ca> wrote in message
news:d8**********************@wagner.videotron.net ...
Hi all!!

I need your help.... i'm working since 2 hours on a simple insert statement, but couldn't handle it.

Here is my code :

public int ExecQuery(string SqlString)

{
OleDbConnection oCoon = new OleDbConnection(connectionString);

oCoon.Open();

OleDbCommand cmd3 = new OleDbCommand();

cmd3.Connection = oCoon;

cmd3.CommandText = SqlString;

if(oCoon.State == ConnectionState.Closed)

{

oCoon.Open();

}

cmd3.ExecuteNonQuery();

return 1

}

When the code reach the cmd3.ExecuteNonQuery(); I always receive the
followin error :

SYNTAX ERROR IN INSERT INTO STATEMENT....

But, i tried to put some debug info (Debug.Write) and my SQL statement seem ok.

SQL Statement : INSERT INTO COLORS (agent_no,primary,secondary) VALUES
(3,'fff','ALLO')

Any idea??

Thanks,

Nov 18 '05 #2
Thanks, that was the problem!!
"William Gower" <w_*****@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP12.phx.gbl...
primary is a reserved word. Put this instead [primary]

"eric dugal" <er********@videotron.ca> wrote in message
news:d8**********************@wagner.videotron.net ...
Hi all!!

I need your help.... i'm working since 2 hours on a simple insert

statement,
but couldn't handle it.

Here is my code :

public int ExecQuery(string SqlString)

{
OleDbConnection oCoon = new OleDbConnection(connectionString);

oCoon.Open();

OleDbCommand cmd3 = new OleDbCommand();

cmd3.Connection = oCoon;

cmd3.CommandText = SqlString;

if(oCoon.State == ConnectionState.Closed)

{

oCoon.Open();

}

cmd3.ExecuteNonQuery();

return 1

}

When the code reach the cmd3.ExecuteNonQuery(); I always receive the
followin error :

SYNTAX ERROR IN INSERT INTO STATEMENT....

But, i tried to put some debug info (Debug.Write) and my SQL statement

seem
ok.

SQL Statement : INSERT INTO COLORS (agent_no,primary,secondary) VALUES
(3,'fff','ALLO')

Any idea??

Thanks,


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Gérard Leclercq | last post by:
ACCESS First fields are TEXT, last 2 are Numbers The name of the fields are correct. Dim MyConn Set MyConn=Server.CreateObject("ADODB.Connection") MyConn.Open...
4
by: dcarson | last post by:
I've read about this error in several other discussions, but still can't seem to pinpoint the problem with my code. Everything seemed to be working fine for some time, but it now tends to bomb out...
3
by: William | last post by:
i am using a dataset and a DataAdapter to update a table with the following schema: ResourceID ProjectID LastName FirstName Year Nov Dec Jan
7
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...
3
by: Neil Zanella | last post by:
Hello, I am trying to execute ADO.NET INSERT statement where one of the fields is coming from a password HTML control. When I access the text with password.Value and print with Response.Write...
3
by: Nathan Sokalski | last post by:
When trying to submit data to an Access database using ASP.NET I recieve the following error: System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr) +41...
5
by: amitbadgi | last post by:
Hi guys, I am getting the following error in teh insert statement , I am converting this asp application to asp.net, here is teh error, Exception Details:...
2
by: RSH | last post by:
I have a rather simple script that transfers data from a SQL server database to an Access database. The procedure is intended to be dynamic so I am basically adding a datarow and then passing the...
6
by: ewpatton | last post by:
Good day, I've been trying to work with SQL and an Access database in order to handle custom user profiles. I haven't had any trouble reading from my database, but inserting new entries into...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.