Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Insert Error


Message #1 by "Reetu Mathur" <reetu_m@h...> on Mon, 23 Dec 2002 15:09:37
Hello,

I am having problems inserting records into an Access Database

Here is my SQL Query 

Dim objCommand, objRS, indexNum,intNoOfRecords
Set objCommand = Server.CreateObject("ADODB.Command")
date_insert = Request.Form("date_text_bx")    
city_insert = Request.Form("city_text_bx")
type_insert = Request.Form("type_drop_box")
code_insert = Request.Form("code_text_bx")
state_insert = Request.Form("state_drop_bx")

objCommand.ActiveConnection = strConnect
objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert 
&"','"& city_insert & "','"& type_insert &"','" & code_insert&"','" 
&state_insert &" ');"

objCommand.CommandType = adCmdText
objCommand.Execute intNoOfRecords
Set objCommand = Nothing 

And here is the error that i get : - 

Microsoft JET Database Engine error '80040e14' 
Syntax error in INSERT INTO statement. 
/admin_process_insert_event.asp, line 111 

The fildes in my database are all text except the date field which is of 
type Date/Time.

Can any one suggest what is the poosible cause of this error

Thanks in advance,

Reetu Mathur
Message #2 by Greg Griffiths <greg2@s...> on Mon, 23 Dec 2002 20:05:31 +0000
Try printing the CommandText to the screen to see what you have and then 
try running that in an Access SQL Session, I think you may have a problem 
with the date parts.

At 15:09 23/12/02 +0000, you wrote:
>Hello,
>
>I am having problems inserting records into an Access Database
>
>Here is my SQL Query
>
>Dim objCommand, objRS, indexNum,intNoOfRecords
>Set objCommand = Server.CreateObject("ADODB.Command")
>date_insert = Request.Form("date_text_bx")
>city_insert = Request.Form("city_text_bx")
>type_insert = Request.Form("type_drop_box")
>code_insert = Request.Form("code_text_bx")
>state_insert = Request.Form("state_drop_bx")
>
>objCommand.ActiveConnection = strConnect
>objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert
>&"','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
>&state_insert &" ');"
>
>objCommand.CommandType = adCmdText
>objCommand.Execute intNoOfRecords
>Set objCommand = Nothing
>
>And here is the error that i get : -
>
>Microsoft JET Database Engine error '80040e14'
>Syntax error in INSERT INTO statement.
>/admin_process_insert_event.asp, line 111
>
>The fildes in my database are all text except the date field which is of
>type Date/Time.
>
>Can any one suggest what is the poosible cause of this error
>
>Thanks in advance,
>
>Reetu Mathur



Message #3 by "padmaja" <padmaja.jaganmohan@w...> on Tue, 24 Dec 2002 08:23:45 +0530
Try executing after removing the semicolon.

-----Original Message-----
From: Reetu Mathur [mailto:reetu_m@h...]
Sent: Monday, December 23, 2002 3:10 PM
To: ASP Databases
Subject: [asp_databases] Insert Error


Hello,

I am having problems inserting records into an Access Database

Here is my SQL Query

Dim objCommand, objRS, indexNum,intNoOfRecords
Set objCommand = Server.CreateObject("ADODB.Command")
date_insert = Request.Form("date_text_bx")
city_insert = Request.Form("city_text_bx")
type_insert = Request.Form("type_drop_box")
code_insert = Request.Form("code_text_bx")
state_insert = Request.Form("state_drop_bx")

objCommand.ActiveConnection = strConnect
objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert
&"','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
&state_insert &" ');"

objCommand.CommandType = adCmdText
objCommand.Execute intNoOfRecords
Set objCommand = Nothing

And here is the error that i get : -

Microsoft JET Database Engine error '80040e14'
Syntax error in INSERT INTO statement.
/admin_process_insert_event.asp, line 111

The fildes in my database are all text except the date field which is of
type Date/Time.

Can any one suggest what is the poosible cause of this error

Thanks in advance,

Reetu Mathur


Message #4 by "Jonas Skafte Jensen" <jskaftejensen@h...> on Tue, 24 Dec 2002 04:34:12 +0100
I think you need to put #s around your date(s) in Access.

Try changing this:

objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert
&"','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
&state_insert &" ');"

into this:

objCommand.CommandText = "INSERT INTO Schedule VALUES('#"& date_insert
&"#','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
&state_insert &" ');"

or this:

objCommand.CommandText = "INSERT INTO Schedule VALUES(#"& date_insert
&"#,'"& city_insert & "','"& type_insert &"','" & code_insert&"','"
&state_insert &" ');"

I can't remember if you need the 's too, when using dates. SQL Server, which
I use the most now, has a different syntax.


----- Original Message -----
From: "padmaja" <padmaja.jaganmohan@w...>
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, December 24, 2002 3:53 AM
Subject: [asp_databases] RE: Insert Error


> Try executing after removing the semicolon.
>
> -----Original Message-----
> From: Reetu Mathur [mailto:reetu_m@h...]
> Sent: Monday, December 23, 2002 3:10 PM
> To: ASP Databases
> Subject: [asp_databases] Insert Error
>
>
> Hello,
>
> I am having problems inserting records into an Access Database
>
> Here is my SQL Query
>
> Dim objCommand, objRS, indexNum,intNoOfRecords
> Set objCommand = Server.CreateObject("ADODB.Command")
> date_insert = Request.Form("date_text_bx")
> city_insert = Request.Form("city_text_bx")
> type_insert = Request.Form("type_drop_box")
> code_insert = Request.Form("code_text_bx")
> state_insert = Request.Form("state_drop_bx")
>
> objCommand.ActiveConnection = strConnect
> objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert
> &"','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
> &state_insert &" ');"
>
> objCommand.CommandType = adCmdText
> objCommand.Execute intNoOfRecords
> Set objCommand = Nothing
>
> And here is the error that i get : -
>
> Microsoft JET Database Engine error '80040e14'
> Syntax error in INSERT INTO statement.
> /admin_process_insert_event.asp, line 111
>
> The fildes in my database are all text except the date field which is of
> type Date/Time.
>
> Can any one suggest what is the poosible cause of this error
>
> Thanks in advance,
>
> Reetu Mathur
>
>
>
>
Message #5 by "M.Nataraj" <nataraj@f...> on Tue, 24 Dec 2002 10:15:46 +0530
Hi,

    Why do u have to Insert using a Adodb.Command ? any specify reason for
it ? u can do the same Insert with the Connection Object as given below ..
coding is a very less ..

' Storing the Sql Query in a Variable
strSql = ""INSERT INTO Schedule VALUES('"& date_insert &"','"& city_insert &
"','"& type_insert &"','" & code_insert&"','" &state_insert &"')"

strConnect.Execute strSql

also its a good practice to Trim the Values before u insert in to the table

Regards,
Nataraj




----- Original Message -----
From: "padmaja" <padmaja.jaganmohan@w...>
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, December 24, 2002 8:23 AM
Subject: [asp_databases] RE: Insert Error


> Try executing after removing the semicolon.
>
> -----Original Message-----
> From: Reetu Mathur [mailto:reetu_m@h...]
> Sent: Monday, December 23, 2002 3:10 PM
> To: ASP Databases
> Subject: [asp_databases] Insert Error
>
>
> Hello,
>
> I am having problems inserting records into an Access Database
>
> Here is my SQL Query
>
> Dim objCommand, objRS, indexNum,intNoOfRecords
> Set objCommand = Server.CreateObject("ADODB.Command")
> date_insert = Request.Form("date_text_bx")
> city_insert = Request.Form("city_text_bx")
> type_insert = Request.Form("type_drop_box")
> code_insert = Request.Form("code_text_bx")
> state_insert = Request.Form("state_drop_bx")
>
> objCommand.ActiveConnection = strConnect
> objCommand.CommandText = "INSERT INTO Schedule VALUES('"& date_insert
> &"','"& city_insert & "','"& type_insert &"','" & code_insert&"','"
> &state_insert &" ');"
>
> objCommand.CommandType = adCmdText
> objCommand.Execute intNoOfRecords
> Set objCommand = Nothing
>
> And here is the error that i get : -
>
> Microsoft JET Database Engine error '80040e14'
> Syntax error in INSERT INTO statement.
> /admin_process_insert_event.asp, line 111
>
> The fildes in my database are all text except the date field which is of
> type Date/Time.
>
> Can any one suggest what is the poosible cause of this error
>
> Thanks in advance,
>
> Reetu Mathur
>
>
>
>

Message #6 by khalid qureshi <khalidone@y...> on Mon, 23 Dec 2002 22:18:38 -0800 (PST)
Thanks for your reply. Your reply has been of great
help for me. I used the same code which worked. thanks

khalid

--- "M.Nataraj" <nataraj@f...> wrote:
> Hi,
> 
>     Why do u have to Insert using a Adodb.Command ?
> any specify reason for
> it ? u can do the same Insert with the Connection
> Object as given below ..
> coding is a very less ..
> 
> ' Storing the Sql Query in a Variable
> strSql = ""INSERT INTO Schedule VALUES('"&
> date_insert &"','"& city_insert &
> "','"& type_insert &"','" & code_insert&"','"
> &state_insert &"')"
> 
> strConnect.Execute strSql
> 
> also its a good practice to Trim the Values before u
> insert in to the table
> 
> Regards,
> Nataraj
> 
> 
> 
> 
> ----- Original Message -----
> From: "padmaja" <padmaja.jaganmohan@w...>
> To: "ASP Databases" <asp_databases@p...>
> Sent: Tuesday, December 24, 2002 8:23 AM
> Subject: [asp_databases] RE: Insert Error
> 
> 
> > Try executing after removing the semicolon.
> >
> > -----Original Message-----
> > From: Reetu Mathur [mailto:reetu_m@h...]
> > Sent: Monday, December 23, 2002 3:10 PM
> > To: ASP Databases
> > Subject: [asp_databases] Insert Error
> >
> >
> > Hello,
> >
> > I am having problems inserting records into an
> Access Database
> >
> > Here is my SQL Query
> >
> > Dim objCommand, objRS, indexNum,intNoOfRecords
> > Set objCommand 
> Server.CreateObject("ADODB.Command")
> > date_insert = Request.Form("date_text_bx")
> > city_insert = Request.Form("city_text_bx")
> > type_insert = Request.Form("type_drop_box")
> > code_insert = Request.Form("code_text_bx")
> > state_insert = Request.Form("state_drop_bx")
> >
> > objCommand.ActiveConnection = strConnect
> > objCommand.CommandText = "INSERT INTO Schedule
> VALUES('"& date_insert
> > &"','"& city_insert & "','"& type_insert &"','" &
> code_insert&"','"
> > &state_insert &" ');"
> >
> > objCommand.CommandType = adCmdText
> > objCommand.Execute intNoOfRecords
> > Set objCommand = Nothing
> >
> > And here is the error that i get : -
> >
> > Microsoft JET Database Engine error '80040e14'
> > Syntax error in INSERT INTO statement.
> > /admin_process_insert_event.asp, line 111
> >
> > The fildes in my database are all text except the
> date field which is of
> > type Date/Time.
> >
> > Can any one suggest what is the poosible cause of
> this error
> >
> > Thanks in advance,
> >
> > Reetu Mathur
> >
> >
> >
> >
> 
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

  Return to Index