Results 1 to 8 of 8

Thread: *** RESOLVED *** ASP >> SQL SELECT * and WHERE ? How does it work?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    *** RESOLVED *** ASP >> SQL SELECT * and WHERE ? How does it work?

    Hi,

    I extend now my question.

    I am currently creating a ASP-FIle in which I want to use only selected data. This data I want to get with:

    numID_Region = 2
    numID_Area = 4

    I got already the answer if I use WHERE with one option, How i can use WHERE with two options?

    With one option I got this answer here and it works fine (Thanks):
    Set rstProvince = CreateObject("ADODB.Recordset")
    rstProvince.Open "SELECT * FROM Guide WHERE ID_Region = " & numID_Region & " ORDER BY ID_Region, ID_Province", con


    So, now the question, how can I include the second Restriction?


    Thanks in advance for your help
    Franky



    I found the solution, thanks!
    Last edited by Franky; Feb 4th, 2002 at 02:03 PM.

  2. #2
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    ASP doesn't know your SQL string from any other string, and VBScript doesn't offer cool variable interpolation like Perl, so:

    Code:
    rstProvince.Open "SELECT * FROM Guide WHERE ID_Region = " & numID_Region & " ORDER BY ID_Region, ID_Province", con
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Thanks it works

    Thanks, it works.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Only to bring the question back to page 1

    ..

  5. #5
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    VB Code:
    1. rstProvince.Open "SELECT * FROM Guide WHERE ID_Region = " & numID_Region & " AND ID_Area = " & numID_Area & " ORDER BY ID_Region, ID_Province", con

    You're simply creating an SQL string dynamically.
    Last edited by JoshT; Feb 4th, 2002 at 11:50 AM.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Hi JoshT

    I did exactly what you showed me here.

    Maybe it was a writing error from my side. I will check it again.

    Thanks

  7. #7
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Use:

    Code:
    select * from TableName where Fieldname1 = '" & myvar & "'  and FieldName2 = '" & myvar2 & "'"
    Hope this helps.

  8. #8
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Re: Hi JoshT

    Originally posted by Franky
    I did exactly what you showed me here.

    Maybe it was a writing error from my side. I will check it again.

    Thanks
    I edited out a small typo - let us know if you get specific error messages.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

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



Click Here to Expand Forum to Full Width