Syntax error in insert statement

E

eric dugal

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,
 
E

eric dugal

Thanks, that was the problem!!


William Gower said:
primary is a reserved word. Put this instead [primary]

eric dugal said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top