Merge two recordset objects
Posted on 1998-12-02
I have two recordsets objects which are currently open.
One of these has xx no. of dummy fields . I want to add
column values of the other recordset object in these dummy columns for each row. In short i want to merge the result of these two recordset objects
coz i have to send a single VARIANT object back to the client App from my DLL
Here is my sample code which fails for some reason.
'col1 is int and col2 is text
'MSSQL server 7.0 ADO 2.0
cmd.CommandText = "select col1,col2 from table Sample1"
Dim record As New ADODB.Recordset
record.CursorLocation = adUseClient
record.Open cmd, , adOpenForwardOnly, adLockReadOnly, adCmdText
cmd.CommandText = "select 0,'x', col3, col4 from Sample2"
Dim record1 As New ADODB.Recordset
record1.CursorLocation = adUseClient
record1.Open cmd, , adOpenForwardOnly, adLockReadOnly, adCmdText
if record.GetCount > record1.GetCount Then
do while not record.EOF
record1.Fields(0).Value = record.Fields(0).Value
record1.Fields(1).Value = record.Fields(1).Value