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 3 of 3

Thread: Asp & Sql

  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New Coder
    Join Date
    Jun 2002
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Concatenation

    Thanks a lot Obiwan and Dave.

    That works nicely.


  •  

    Posting Permissions

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