Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Syntax error in insert statement (http://www.velocityreviews.com/forums/t83931-syntax-error-in-insert-statement.html)

eric dugal 07-31-2004 04:41 PM

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,



William Gower 07-31-2004 04:49 PM

Re: Syntax error in insert statement
 
primary is a reserved word. Put this instead [primary]

"eric dugal" <eric.dugal@videotron.ca> wrote in message
news:d8POc.113688$9Y2.1051995@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,
>
>




eric dugal 07-31-2004 11:34 PM

Re: Syntax error in insert statement
 
Thanks, that was the problem!!


"William Gower" <w_gower@hotmail.com> a écrit dans le message de
news:%23vyCU4xdEHA.3664@TK2MSFTNGP12.phx.gbl...
> primary is a reserved word. Put this instead [primary]
>
> "eric dugal" <eric.dugal@videotron.ca> wrote in message
> news:d8POc.113688$9Y2.1051995@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,
> >
> >

>
>





All times are GMT. The time now is 04:48 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.