Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Syntax error in insert statement

Reply
Thread Tools

Syntax error in insert statement

 
 
eric dugal
Guest
Posts: n/a
 
      07-31-2004
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,


 
Reply With Quote
 
 
 
 
William Gower
Guest
Posts: n/a
 
      07-31-2004
primary is a reserved word. Put this instead [primary]

"eric dugal" <(E-Mail Removed)> wrote in message
news:d8POc.113688$(E-Mail Removed) ...
> 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,
>
>



 
Reply With Quote
 
 
 
 
eric dugal
Guest
Posts: n/a
 
      07-31-2004
Thanks, that was the problem!!


"William Gower" <(E-Mail Removed)> a écrit dans le message de
news:%(E-Mail Removed)...
> primary is a reserved word. Put this instead [primary]
>
> "eric dugal" <(E-Mail Removed)> wrote in message
> news:d8POc.113688$(E-Mail Removed) ...
> > 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,
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL syntax error in INSERT INTO statement Nathan Sokalski ASP .Net 5 09-03-2010 02:12 AM
Syntax error in INSERT INTO statement Gérard Leclercq ASP General 6 02-02-2005 03:11 PM
password field: Syntax error in INSERT INTO statement. Neil Zanella ASP .Net 3 01-25-2005 02:49 AM
Syntax error in INSERT INTO statement Saber ASP .Net 5 07-20-2004 11:26 AM
adapter update problem Syntax error in INSERT INTO statement. compuglobalhypermeganetz0r ASP .Net 0 12-08-2003 05:03 AM



Advertisments