getrows breaks if WHERE in sql

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default getrows breaks if WHERE in sql

    Hello all willing to assist. This should be simple but it's killing me. I
    have this query (Access2k):

    strsql="SELECT M.NewRingNum "

    strsql= strsql & "FROM tblMain M "

    strsql= strsql & "WHERE M.NewRingNum LIKE 'PH*' "

    strsql= strsql & "ORDER BY M.NewRingNum;"

    If run in access it returns a column of information begining with PH like
    you would assume. If I insert it into an ASP page and try to set it to
    getrows I get an error. Specifically:

    Error Type:
    ADODB.Recordset (0x800A0BCD)
    Either BOF or EOF is True, or the current record has been deleted. Requested
    operation requires a current record.


    I'm doing it like this:

    strConn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    server.mappath("RingTracker_Web.mdb") & ";"


    set rsTMP=server.createobject("adodb.recordset")

    rsTMP.open strsql, strconn


    alldata=rstmp.getrows '<< Error happens here


    rstmp.close

    set rstmp=nothing

    set strconn=nothing

    If I comment out the WHERE part, it works. ANY thoughts are appreciated. I'm
    stumped.

    TIA

    David



    DavidT Guest

  2. Similar Questions and Discussions

    1. Paging and getrows
      Assuming the code below, whats the most efficient way to get the actual record count as the full array count doesnt exist :-) I want to keep the...
    2. Getrows = funny result
      Hi, I want to use Getrows on a recordset. using 3 recordsets: set rs2003 = Server.CreateObject("ADODB.recordset") set rs2002 =...
    3. GetRows and ASP 2.0
      Hello, Are there a lot of differences between ASP 2.0 and 3.0. My development environment is a bit more up to date then my production system. I...
    4. GetRows Mystery
      I'm facing an odd behavior in using the GetRows Method. I'm not sure what's causing it because it has been working fine until now. I have a sproc...
    5. Using GetRows()
      I am getting information out of a table to place into to an Array. rs=DataConn.Execute(strSQL) At this point I place it into the array ...
  3. #2

    Default Re: getrows breaks if WHERE in sql

    Your problem isn't with the fact that you're using WHERE. It's that when
    you're using WHERE, you're getting no records back, and you're trying to
    GetRows on an empty recordset. That means that there are no records that
    are like 'PH*'. With ADO, use % instead of * for your wildcard (even with
    Access).

    Always check for EOF!

    If Not rstemp.EOF Then alldata = rstemp.GetRows()
    rsTemp.Close : Set rsTemp = Nothing
    '''close and destroy connection

    If Not IsEmpty(alldata) Then
    '''do stuff
    Else
    Response.Write "0 records"
    End If

    Ray at work


    "DavidT" <david.timm@t-mobile.com> wrote in message
    news:ewSkYjMIEHA.2744@TK2MSFTNGP10.phx.gbl...
    > Hello all willing to assist. This should be simple but it's killing me. I
    > have this query (Access2k):
    >
    > strsql="SELECT M.NewRingNum "
    >
    > strsql= strsql & "FROM tblMain M "
    >
    > strsql= strsql & "WHERE M.NewRingNum LIKE 'PH*' "
    >
    > strsql= strsql & "ORDER BY M.NewRingNum;"
    >
    > If run in access it returns a column of information begining with PH like
    > you would assume. If I insert it into an ASP page and try to set it to
    > getrows I get an error. Specifically:
    >
    > Error Type:
    > ADODB.Recordset (0x800A0BCD)
    > Either BOF or EOF is True, or the current record has been deleted.
    Requested
    > operation requires a current record.
    >
    >
    > I'm doing it like this:
    >
    > strConn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    > server.mappath("RingTracker_Web.mdb") & ";"
    >
    >
    > set rsTMP=server.createobject("adodb.recordset")
    >
    > rsTMP.open strsql, strconn
    >
    >
    > alldata=rstmp.getrows '<< Error happens here

    Ray at Guest

  4. #3

    Default Re: getrows breaks if WHERE in sql

    Ray...Ya da MAN! It was the % that was killing y RS. That's why I would get
    data by running the query in Access. I didn't know that was an ADO thing. I
    thought it was SQL Server vs Access thing. I made the switch and it works!

    Normally I'd check for EOF but there will ALWAYS be values for this RS.
    Always. 100% of the time.

    Thanks again. You made my Monday.
    David - also at work.

    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:exL25vMIEHA.700@TK2MSFTNGP09.phx.gbl...
    > Your problem isn't with the fact that you're using WHERE. It's that when
    > you're using WHERE, you're getting no records back, and you're trying to
    > GetRows on an empty recordset. That means that there are no records that
    > are like 'PH*'. With ADO, use % instead of * for your wildcard (even with
    > Access).
    >
    > Always check for EOF!
    >
    > If Not rstemp.EOF Then alldata = rstemp.GetRows()
    > rsTemp.Close : Set rsTemp = Nothing
    > '''close and destroy connection
    >
    > If Not IsEmpty(alldata) Then
    > '''do stuff
    > Else
    > Response.Write "0 records"
    > End If
    >
    > Ray at work
    >
    >
    > "DavidT" <david.timm@t-mobile.com> wrote in message
    > news:ewSkYjMIEHA.2744@TK2MSFTNGP10.phx.gbl...
    > > Hello all willing to assist. This should be simple but it's killing me.
    I
    > > have this query (Access2k):
    > >
    > > strsql="SELECT M.NewRingNum "
    > >
    > > strsql= strsql & "FROM tblMain M "
    > >
    > > strsql= strsql & "WHERE M.NewRingNum LIKE 'PH*' "
    > >
    > > strsql= strsql & "ORDER BY M.NewRingNum;"
    > >
    > > If run in access it returns a column of information begining with PH
    like
    > > you would assume. If I insert it into an ASP page and try to set it to
    > > getrows I get an error. Specifically:
    > >
    > > Error Type:
    > > ADODB.Recordset (0x800A0BCD)
    > > Either BOF or EOF is True, or the current record has been deleted.
    > Requested
    > > operation requires a current record.
    > >
    > >
    > > I'm doing it like this:
    > >
    > > strConn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" &
    > > server.mappath("RingTracker_Web.mdb") & ";"
    > >
    > >
    > > set rsTMP=server.createobject("adodb.recordset")
    > >
    > > rsTMP.open strsql, strconn
    > >
    > >
    > > alldata=rstmp.getrows '<< Error happens here
    >
    >

    DavidT Guest

  5. #4

    Default Re: getrows breaks if WHERE in sql

    Cool. Glad it worked.

    IMO, there is no such thing as ALWAYS, but that's just me. :]

    Rya at work

    "DavidT" <david.timm@t-mobile.com> wrote in message
    news:O4Z1d4MIEHA.2576@TK2MSFTNGP09.phx.gbl...
    > Ray...Ya da MAN! It was the % that was killing y RS. That's why I would
    get
    > data by running the query in Access. I didn't know that was an ADO thing.
    I
    > thought it was SQL Server vs Access thing. I made the switch and it works!
    >
    > Normally I'd check for EOF but there will ALWAYS be values for this RS.
    > Always. 100% of the time.
    >
    > Thanks again. You made my Monday.
    > David - also at work.
    >
    > "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    > message news:exL25vMIEHA.700@TK2MSFTNGP09.phx.gbl...
    > > Your problem isn't with the fact that you're using WHERE. It's that
    when
    > > you're using WHERE, you're getting no records back, and you're trying to
    > > GetRows on an empty recordset. That means that there are no records
    that
    > > are like 'PH*'. With ADO, use % instead of * for your wildcard (even
    with
    > > Access).
    > >
    > > Always check for EOF!

    Ray at Guest

  6. #5

    Default Re: getrows breaks if WHERE in sql

    Funny thing was...not 10 seconds after sending that I said "I wonder...."
    and proved myself wrong. =)

    I then added code to comepnsate for EOF and humbly change my reply to ALMOST
    always.

    Thanks again.


    "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    message news:#GBa58MIEHA.3720@tk2msftngp13.phx.gbl...
    > Cool. Glad it worked.
    >
    > IMO, there is no such thing as ALWAYS, but that's just me. :]
    >
    > Rya at work
    >
    > "DavidT" <david.timm@t-mobile.com> wrote in message
    > news:O4Z1d4MIEHA.2576@TK2MSFTNGP09.phx.gbl...
    > > Ray...Ya da MAN! It was the % that was killing y RS. That's why I would
    > get
    > > data by running the query in Access. I didn't know that was an ADO
    thing.
    > I
    > > thought it was SQL Server vs Access thing. I made the switch and it
    works!
    > >
    > > Normally I'd check for EOF but there will ALWAYS be values for this RS.
    > > Always. 100% of the time.
    > >
    > > Thanks again. You made my Monday.
    > > David - also at work.
    > >
    > > "Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
    > > message news:exL25vMIEHA.700@TK2MSFTNGP09.phx.gbl...
    > > > Your problem isn't with the fact that you're using WHERE. It's that
    > when
    > > > you're using WHERE, you're getting no records back, and you're trying
    to
    > > > GetRows on an empty recordset. That means that there are no records
    > that
    > > > are like 'PH*'. With ADO, use % instead of * for your wildcard (even
    > with
    > > > Access).
    > > >
    > > > Always check for EOF!
    >
    >

    DavidT Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139