Web Analytics Made Easy -
StatCounter Asp & Sql - CodingForum

Announcement

Collapse
No announcement yet.

Asp & Sql

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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

    Comment


    • #3
      Concatenation

      Thanks a lot Obiwan and Dave.

      That works nicely.

      Comment

      Working...
      X