Array and query

Results 1 to 4 of 4

Thread: Array and query

  1. #1
    Marina Soutorikhina Guest

    Default Array and query

    I need to show records from a q-ry string in the URL with the range of IDs. I have code - Array<BR>Dim MyArray<BR> <BR>MyArray = Request.QueryString("BoardNumber")<BR>MyArray = Split(MyArray, ",")<BR> <BR>For i=0 to Ubound(MyArray)<BR>&#039;Response.Write MyArray(i)&"<BR>"<BR>vboardNumber = MyArray(I)<BR>Response.Write vboardNumber&" "<BR>NExt<BR><BR>and a q-ry<BR><BR> vSQL= " SELECT * From Board "<BR> vSQL = vSQL & "WHERE" <BR> vSQL=vSQL & " Board.BoardNumber LIKE &#039;%" & vBoardNumber & "%&#039; "<BR> rsBoard.Open vSQL,DataConn,3,3 <BR> <BR> vSQL = vSQL & " order by Board.BoardNumber "<BR>How can I pass the BoardNumber values to the q-ry?

  2. #2
    Join Date
    Dec 1969

    Default IN operator

    First you generate the vBoardNumber as a comma separated value. Then do the query like this...<BR><BR>vSQL= " SELECT * From Board "<BR>vSQL = vSQL & "WHERE" <BR>vSQL=vSQL & " Board.BoardNumber IN (vBoardNumber)"<BR>

  3. #3
    Join Date
    Dec 1969

    Default Right idea, wrong code...

    vBoardNumber in that code is a *single* number. You need the entire string, *WITH* the commas in place.<BR><BR>Also, that SQL would be looking for a field in the table named "vBoardNumber". You never do use any VBScript variable in making the query.<BR><BR>If the field "BoardNumber" in the DB is a NUMERIC field of any kind, then the answer is as simple as:<BR> vSQL = "SELECT * From Board WHERE BoardNumber IN (" & Request("BoardNumber") & ")"<BR><BR>If the field is *not* numeric, then...<BR><BR>This *IS* covered in the ASPFAQs! The link to the ASPFAQs is on this very page, just to make it easy to find answer to questions like this one.<BR><BR><BR><BR><BR>

  4. #4
    Marina Soutorikhina Guest

    Default RE: Right idea, wrong code...

    Fortunately I have a numeric field. This code works terrific! Thanks!!! Now I&#039;ll have a good weekend.

Posting Permissions

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