Re: Stand Alone Recordsets
- From: Ilanio <Ilanio@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 19 Jan 2007 19:00:00 -0800
Ok, so the answer is: "not possible to create a new stand alone recordset,
using a SQL query on two opened stand alone recordsets"...
The method of loop in data of recordsets is very expensive for a large
number of rows...
Anyway, thanks.
Ilanio
"Bob Barrows [MVP]" wrote:
Ilanio wrote:.
Note the sample code I made in VBScript:
'--------------------------------------------------
Set rst = CreateObject("ADODB.Recordset")
rst.CursorLocation = 3 ' adUseClient
rst.CursorType = 1 ' adOpenKeyset
rst.LockType = 3 ' adLockOptimistic
I believe these settings are ignored for ad hoc recordsets.
<snip>
<snip>
'Now I have another recordset
Set rts = CreateObject("ADODB.Recordset")
'Now I want to create a new recordset with data in the recordset 1
(rst) 'equals in the recordset 2 (rts)
'I try something like the code below withou success:
Set res = CreateObject("ADODB.Recordset")
res.CursorLocation = 3 ' adUseClient
res.CursorType = 1 ' adOpenKeyset
res.LockType = 3 ' adLockOptimistic
res.Open "SELECT rst.* FROM rst INNER JOIN rts ON rst.Name = rts.Name"
'The above line produces error
Of course it does. ADO is not a database engine. you need a database
engine to run sql statements ... as I said in my initial reply:
No. You need a database engine to execute sql statements. None
exists in this situation. You will need to run nested loops.
IOW, you are going to need to create a third ad hoc recordset and
populate it by looping through one of the first two recordsets you
created. something like this:
Set res = CreateObject("ADODB.Recordset")
res.Fields.Append "Name", 200, 255 ' adVarChar
res.Open
rst.MoveFirst
Dim sName
Do Until rst.EOF
sName = rst(0).value
rts.Filter = "Name='" & sName & "'"
if not rts.EOF then
res.AddNew "Name", sName
End If
rts.Filter = ""
rst.MoveNext
Loop
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
- Follow-Ups:
- Re: Stand Alone Recordsets
- From: Stephen Howe
- Re: Stand Alone Recordsets
- References:
- Re: Stand Alone Recordsets
- From: Bob Barrows [MVP]
- Re: Stand Alone Recordsets
- From: Ilanio
- Re: Stand Alone Recordsets
- From: Bob Barrows [MVP]
- Re: Stand Alone Recordsets
- Prev by Date: Re: Stand Alone Recordsets
- Next by Date: Re: msdatashape provider error
- Previous by thread: Re: Stand Alone Recordsets
- Next by thread: Re: Stand Alone Recordsets
- Index(es):
Relevant Pages
|
|