General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 15th, 2002, 09:34 PM
arossphoto arossphoto is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 1 arossphoto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL syntax error '80004005'

Can anyone at all help me out with this one?

I am trying to convert my asp pages from Access to MySQL and have run into some problems with SQL syntax. My first insert page inserts new contact information such as name and address into table Contacts. Each contact can belong to several categories, so I also have a table called Categories and a table between the two called ContactCategories. The second insert page lists all the categories with check boxes and should insert the appropriate combinations of Contact_ID and Category_ID into table ContactCategories.

The pages have worked flawlessly for almost a year with an Access database. I'm trying to convert to MySQL and now the second page generates the error below:

ADODB.Connection.1 error '80004005'
SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near ')' at line 1

/canphotodirect/insert_pg2.asp, line 102


This is the code that seems to be causing the problem. Line 102 is "Command1.Execute()":

<%
If Request("chkCategories" & (rsCategories.Fields.Item("Category_ID").Value)) <> "" Then

set Command1 = Server.CreateObject("ADODB.Command")

Command1.ActiveConnection = MM_canphoto_STRING

Command1.CommandText = "INSERT INTO ContactCategories (Category_ID, Contact_ID) VALUES (" + Replace(Command1__varCategories, "'", "''") + ", " + Replace(Command1__varContact_ID, "'", "''") + ") "

Command1.CommandType = 1

Command1.CommandTimeout = 0

Command1.Prepared = true

Command1.Execute()

End If
%>

If anyone can help I would really appreciate it. My update page also generates the same error, but it works perfectly with Access too.

Cheers,

Andrew

Reply With Quote
  #2  
Old February 9th, 2004, 08:37 PM
merliin's Avatar
merliin merliin is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Melbourne, Australia
Posts: 30 merliin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Command1.CommandText = "INSERT INTO ContactCategories (Category_ID, Contact_ID) VALUES (" + Replace(Command1__varCategories, "'", "''") + ", " + Replace(Command1__varContact_ID, "'", "''") + ") "

This should be "''" according to the rest of your code.

Hope this helps.

Last edited by merliin : February 9th, 2004 at 08:42 PM. Reason: Error not clear enough

Reply With Quote
  #3  
Old February 10th, 2004, 01:41 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Not sure that is correct merlin. What arossphoto is doing there is replacing single quotes with double, which should be done when inserting into a DB.. the replace function parameters are string literal, string to find, string to replace with.

arossphoto - Create you SQL in a string variable first, then response write that string before executing it - that'll show you what the problem. This method, btw, is the best way to debug.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > SQL syntax error '80004005'


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway