navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Using ASP in my SQL query

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Using ASP in my SQL query
Page: [1]
 
hzarabet

 

Posts: 1540
From: New Milford CT USA
Status: offline

 
Using ASP in my SQL query - 6/9/2002 20:32:07   
Hi All:

In a previous thread RDouglass gave a wonderful explanation of incorporating ASP into a SQL query. This would allow me to use "AND" as my joiner between variables while at the same time remove the need to use defaults.

<% DIM mySQL
mySQL = ""

IF Request.Form(field1) > "" THEN
mySQL = mySQL & "field1 = " & Request.Form(field1)
END IF

IF Request.Form(field2) > "" THEN
IF mySQL > "" THEN
mySQL = mySQL & " AND "
END IF
mySQL = mySQL & "field2 = " & Request.Form(field2)
END IF
...
...
%>

This worked great after some tweaking. THEN I TRIED A RESULTS SET GREATER THAN 1 PAGE!!! Page 1 worked, the rest of the pages didn't. SQL error message. It seemed that that the variable was not being carried over to page 2 on up.

Database Results Error
Description: [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'AND'.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

Before I give up on this (as I did all the work already), am I fighting a losing battle? CAN THIS WORK when results are more than one page long?

All help appreciated!!!!

http://www.SigningsHotline.com lists EVERY upcoming athlete autograph appearance in the US and Canada
rdouglass

 

Posts: 9270
From: Biddeford, ME USA
Status: offline

 
RE: Using ASP in my SQL query - 6/10/2002 9:38:16   
Ya know, I have been looking at this and thinking about it some. I do have a page that uses the FP first/next/prev/last buttons and it does work using the type of script we worked on. I have posted the complete code here:

http://www.clarkinsurance.com/hzarabet.htm

Take a look and see if anything jumps out at you. The part you're probably interested in is the last DRW. The first 3 just are drop-downs. This page does work as 'advertised' - the buttons do work without the error you spoke of. My environment is FP2000, WinNT 4.0, IIS 4, FPExt 2000, Access 2000 DB.

Hope it helps...

 

(in reply to hzarabet)
hzarabet

 

Posts: 1540
From: New Milford CT USA
Status: offline

 
RE: Using ASP in my SQL query - 6/10/2002 23:06:40   
It worked! But it blew something else out!!!

Here is why it worked...

Instead of:

IF Request.Form("Sport") <> "" THEN
IF search <> "" THEN
search = search & " AND "
END IF
search = search & "Sport = '::Sport::'"
END IF

I was using:

IF Request.Form("Sport") <> "" THEN
IF search <> "" THEN
search = search & " AND "
END IF
search = search & "Sport = '"&Request.Form("Sport")&"'"
END IF

That made the difference...

Thank you RDouglass for staying with me on this one!

I will start a new thread for what it blew out!!!

http://www.SigningsHotline.com lists EVERY upcoming athlete autograph appearance in the US and Canada

Edited by - hzarabet on 06/10/2002 23:07:19

Edited by - hzarabet on 06/10/2002 23:11:40

(in reply to hzarabet)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Using ASP in my SQL query
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts