Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - StrSQL + and.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

StrSQL + and.

 Post Reply Post Reply
Author
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Topic: StrSQL + and.
    Posted: 23 July 2004 at 9:34am
I'm having an issue getting "and" to work properly in this bit of code. I believe i've written it down correctly and have tried several methods, but I keep getting an error.


Set rsDownload = Server.CreateObject("ADODB.RecordSet")
    strSQL = "SELECT Download_ID, Download_Preview, Download_Preview_Movie, Download_Version, D_FreeCommercial, Download_Name, D_Short, D_Added, Download_Hits, Download_SubCat, DComments "  
    strSQL = strSQL & " FROM " & strDbTable & "Downloads WHERE " & strDbTable & "Downloads.Download_SubCat = " & scid & "AND" & strDbTable & "Downloads.D_Short & AND"
   
        'If the user has selected all or any words then build the where clause with the words to be searched
    If strSearchMode2 = "2" OR strSearchMode2 = "1" Then
   
        'Call the function to build the query
        strSQL = strSQL & BuildSQL ("" & strDbTable & "Downloads.Download_Name", sarySearchWord)
Else
        strSQL = strSQL & """" & strDbTable & "Downloads.Download_Name LIKE '%" & strSearchKeywords & "%'"
    End If




Microsoft OLE DB Provider for SQL Server error '80040e14'

Line 1: Incorrect syntax near 'ANDtblDownloads'.

/c4dportal2/forum/functions/3rdparty/functions_download.asp, line 1026


Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 23 July 2004 at 9:47am

You seem to have your SQL statement a bit confused, firstly you need to put a space on either side of the AND:

scid & " AND " & strDbTable

And at the end of that part of your SQL query you have an & when you don't need one:

strDbTable & "Downloads.D_Short AND "

Back to Top
Badaboem View Drop Down
Senior Member
Senior Member


Joined: 12 April 2002
Location: Netherlands
Status: Offline
Points: 600
Post Options Post Options   Thanks (0) Thanks(0)   Quote Badaboem Quote  Post ReplyReply Direct Link To This Post Posted: 23 July 2004 at 10:28am
Thanks mart. I've rewritten it and the error line has shifted . It still doesn't pass ''and'' for some reason.




Set rsDownload = Server.CreateObject("ADODB.RecordSet")
    strSQL = "SELECT Download_ID, Download_Preview, Download_Preview_Movie, Download_Version, D_FreeCommercial, Download_Name, D_Short, D_Added, Download_Hits, Download_SubCat, DComments "  
    strSQL = strSQL & " FROM " & strDbTable & "Downloads WHERE " & strDbTable & "Downloads.Download_SubCat = " & scid & " AND " & strDbTable & "Downloads.D_Short AND "
   
        'If the user has selected all or any words then build the where clause with the words to be searched
    If strSearchMode2 = "2" OR strSearchMode2 = "1" Then
   
        'Call the function to build the query
        strSQL = strSQL & BuildSQL ("" & strDbTable & "Downloads.Download_Name", sarySearchWord)
Else
        strSQL = strSQL & """" & strDbTable & "Downloads.Download_Name LIKE '%" & strSearchKeywords & "%'"
    End If


Microsoft OLE DB Provider for SQL Server error '80040e14'

Incorrect syntax near the keyword 'AND'.




Edited by Badaboem
Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Post Options Post Options   Thanks (0) Thanks(0)   Quote Semikolon Quote  Post ReplyReply Direct Link To This Post Posted: 28 July 2004 at 8:04am
what does the buildSQL function put out?

on the last line you can remove & """"
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.