Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Hong Kong
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error In SQL Statement

    Hi,
    I am currently developing a shopping cart but had met some difficulties in inserting the delivery chagres.
    The error prompt that there is error in the Selete Statement.
    I had tried but could not spot the error.
    Here is the statement statement

    <%
    WHILE NOT RS.EOF
    weightTotal = weightTotal + ( RS( "product_weight" ) * RS( "cart_quantity" ) )
    'Get Delivery Charges
    sqlString1 = "SELECT user_country, DHL_Country, DHL_Weight, DHL_Price FROM users, DHLCharge" &_
    "WHERE user_id=" & userID & " AND (user_country = DHL_Country " &_
    "AND DHL_Weight LIKE %" & product_category & "%) "
    SET RS = Con.Execute( sqlString1 )
    deliveryCharge = RS( " DHL_Price" )
    orderTotal = orderTotal + ( RS( "product_price" ) * RS( "cart_quantity" ) ) + deliveryCharge

    %>

    I had also attached the script in together with this page.
    Thanks
    Regards
    victoria
    Attached Files Attached Files

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    To debug SQL statements easily, you need to response.write it.
    Try it and you will see the syntax error.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Mar 2003
    Posts
    176
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error In SQL Statement

    this part...
    Code:
     "SELECT user_country, DHL_Country, DHL_Weight, DHL_Price FROM users, DHLCharge" &_
    "WHERE user_id=" & userID & "  ..etc
    should be like this:
    Code:
     "SELECT user_country, DHL_Country, DHL_Weight, DHL_Price FROM users, DHLCharge " &_
    "WHERE user_id=" & userID & "  ..etc
    ie... a space between DHLCharge and the double quote. I set my sql statements out something like this (depending on the statement):
    Code:
    "SELECT user_country, DHL_Country, DHL_Weight, DHL_Price " &_
    "FROM users, DHLCharge " &_
    "WHERE " &_
    "user_id=" & userID & " " &_
    "AND " &_
    "(user_country = DHL_Country " &_
    "AND " &_
    "DHL_Weight LIKE %" & product_category & "%) "
    ..which helps readability as well as the coding.

    hth

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also as GlennGV said, the absolute best way to debug any SQL statement is to response.write it. Then if the error isn't clear, you can paste it into Query Analyzer, and that may help.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    Hong Kong
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,
    I am still working on it and I am afraid there is some other error in the page which cause the error.
    Anyway thank You.
    Vict


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •