Question about recordset

Results 1 to 3 of 3

Thread: Question about recordset

  1. #1
    Join Date
    Dec 1969

    Default Question about recordset

    I want to extract certain bit of information from a already existing recordset<BR><BR>let&#039;s say i have a recordset with names and ages:<BR><BR>paul 10<BR>frank 25<BR>lisa 23<BR>teresa 12<BR>simon 12<BR>dorleen 30<BR><BR>I want to extract from this recordset all those with age = 12, and make a recordset out of the result, so in the end i want to have 2 recordset<BR><BR>paul 10<BR>frank 25<BR>lisa 23<BR>teresa 12<BR>simon 12<BR>dorleen 30<BR><BR>AND<BR><BR>teresa 12<BR>simon 12<BR><BR>I want to be able to scroll forward only on BOTH these recordset<BR><BR>this is what I tried to do and it&#039;s not working:<BR>(let&#039;s assume the first preexisting RS is called objRS)<BR><BR>strCriteria = "age = 12"<BR>objRS.Filter = strCriteria<BR>SET twelveRS = objRS<BR>objRS.Filter = adFilterNone<BR><BR><BR>but i can NOT call twelveRS.MoveNext , it just doesn&#039;t move <BR><BR>I have a feeling that it has something to do with twelveRS not being a LIVE connection<BR><BR>anyone out there, please help<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Question about recordset

    I know this may be a different method from what you are doing, but if it helps you, why not give it a go. First, to create disconnected recordsets, I use a function that connects to the database (access DB) with a text string. Here we go:<BR>&#060;%<BR>Function GetRecordset(strSQL)<BR> Const adOpenStatic = 3<BR> Const adLockReadOnly = 1<BR> Const adUseClient = 3<BR> Dim objRS<BR> Set objRS = Server.CreateObject("ADODB.Recordset")<BR> &#039; Set cursor location:<BR> objRS.CursorLocation = adUseClient<BR> objRS.Open strSQL, "Provider=Microsoft.Jet.OLEDB.4.0;" & _<BR> "Data Source=d:/html/1st-r8com/database/database.mdb", adOpenStatic, adLockReadOnly<BR> &#039; Disconnect, close and return:<BR> Set objRS.ActiveConnection = Nothing<BR> Set GetRecordset = objRS<BR>End Function<BR><BR>%&#062;<BR><BR><BR><BR>Then, I create two seperate recordsets, like so:<BR>&#060;%<BR>sqlstr = "select * from myTable"<BR>set allSet = getRecordSet(sqlStr)<BR>sqlstr = "select * from myTable where age = 12"<BR>set twelveSet = getrecordSet(sqlStr)<BR>%&#062;<BR>And there you have it, two seperate and completely usable recordsets that are not connected to the database.<BR>You can clean up when you are done with them, like so:<BR>&#060;% <BR>Allset.close : twelveSet.close : set allSet=nothing : set twelveSet = nothing<BR>%&#062;<BR>But because the database connection is already closed, if you forgot to do this, it would not cause too much harm.<BR><BR>Don&#039;t let me take credit for the code here. I just modified the code presented on aspFaqs, here:<BR><BR><BR>Good luck!<BR><BR>Edward<BR>

  3. #3
    Join Date
    Dec 1969

    Default You can't copy recordsets

    The reason your attempt didn&#039;t work is because ActiveX objects can&#039;t be copied by simply assigning a reference to one to a second variable.<BR><BR>See my 3 part series on "VBScript Variables and Values" at www.4GuysFromRolla for why this is true.<BR><BR>

Posting Permissions

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