Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-03-2002, 01:16 PM   PM User | #1
rah111
New Coder

 
Join Date: Jun 2002
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
rah111 is an unknown quantity at this point
Asp & Sql

Hi all.

I have a main.asp file calling list.asp with:

... list.asp?the_file&the_race ...

In list.asp I have two querystring requests as follows:

dbf_file=request.querystring(1)
race_str=request.querystring(2)

and an SQL statement as below:

Sql = "SELECT Rno, Tabno, Name, Starts, Wins, Second, Third, Bp, Jock, Weight FROM " & dbf_file

The problem is that I don't want all the records in the data table, but want to apply a WHERE condition to get only those records where race_str equals a variable number passed from main.asp. The data table itself is also variable and is passed from main.asp.

If I knew that the number (race_str) was 5 and that the data table to be accessed (dbf_file) was Test.dbf then I could use:

Sql = "SELECT Rno, Tabno, Name, Starts, Wins, Second, Third,
Bp, Jock, Weight FROM Test.dbf WHERE Rno = 5

However I don't, so I've tried:

Sql = "SELECT Rno, Tabno, Name, Starts, Wins, Second, Third, Bp, Jock, Weight FROM " & dbf_file " WHERE Rno = " & race_str

and I get the following error message:

"Microsoft VBScript compilation error - Expected end of statement"

How do I properly concatenate the explicit SQL statement with the variable values I obtain from the querystring requests?

Can someone help?

Thanks.

Russell.
rah111 is offline   Reply With Quote
Old 07-03-2002, 01:28 PM   PM User | #2
ObiwanJebroni
New Coder

 
Join Date: Jun 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
ObiwanJebroni is an unknown quantity at this point
Sql = "SELECT Rno, Tabno, Name, Starts, Wins, Second, Third, Bp, Jock, Weight FROM " & dbf_file & " WHERE Rno = " & race_str

The correction is in bold.
__________________
-Obiwan Jabroni
May the Schwartz be With You
ObiwanJebroni is offline   Reply With Quote
Old 07-04-2002, 12:16 AM   PM User | #3
rah111
New Coder

 
Join Date: Jun 2002
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
rah111 is an unknown quantity at this point
Concatenation

Thanks a lot Obiwan and Dave.

That works nicely.
rah111 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:50 AM.


Advertisement
Log in to turn off these ads.