Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Syntax error in INSERT INTO statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-14 : 07:33:15
Jassim writes "Can anyone help? I'm using the following asp+sql code but getting the following error:

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

********* BEGING OF CODE **********
Dim conn, rs, strSQL, strIP_Address, news_date

strIP_Address = Request.ServerVariables("REMOTE_ADDR")

news_date = Session("news_year") & "/" & Session("news_month") & "/" & Session("news_day")

news_date = CDate(news_date)

Set conn = Server.CreateObject("ADODB.Connection")

conn.CursorLocation = 3

conn.Open "b4all_news"

Set rs = Server.CreateObject("ADODB.Recordset")

strSQL = "INSERT INTO news (news_date, news_time, category, title, text, breaking, released, news_photo, photo_title, created_date, created_ip) Values ('" & news_date & "', '" & Time & "', '" & Session("news_category") & "', '" & Session("news_title") & "', '" & Session("news_text") & "', '" & Session("is_Breaking") & "', '" & Session("is_release") & "', '" & Session("news_photo") & "', '" & Session("news_photo_title") & "', '" & Now & "', '" & strIP_Address & "')"

Set rs = conn.Execute(strSQL)

Set rs = Nothing
Set conn = Nothing
********* END OF CODE **********"

SamC
White Water Yakist

3467 Posts

Posted - 2003-02-14 : 08:03:24
I'll follow up with another post if I see a syntax error. Here's a way you can find the error yourself:

Write out the query

response.write strSQL

Copy the query and paste it into Query Analyzer.

You'll find the syntax error yourself that way.

Sam
------------------------
No syntax error jumps out at me. Could there be an embedded ' in any of the parameters that should be replaced with '' ?





Edited by - SamC on 02/14/2003 08:06:27
Go to Top of Page
   

- Advertisement -