Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Recordsets

Status
Not open for further replies.

smash81

Programmer
Mar 12, 2001
88
KE
hello,
I need help with ADO Recordsets.
What i need to know is, is it possible to have the fields of a
recordset getting data from other recordsets?
what i mean is, is it possible to assign one field of recordset A and one field of recordset B to a third recordset C?
If so please help me on how this may be done.
 
Not that I know of. Remember that a recordset is no more than a reference to a set of data in (usually) a database.
You can duplicate the reference (the recordset) to the data, but you would still be left with no more than multiple references to the same data. (Wich is great if this is what you are after :)

However, if you are looking for a way to copy data from one database to another simply by taking a copy of the recordset I haven't found any better way than going through the source RS row by row and copy the content to the destination RS.

Good Luck
-Mats Hulten
 
Thank you for the replies.
Let me give some more details.
I have a table with two fields; amount and payment_type.
amount holds the amount of money paid and the payment_type holds the type of payment(Debit/Credit).
Now what i want is to have one recordset having two fields;
one with all the amounts where the type is Debit and the other with all the amounts where the type is Credit.
Is this possible?If so how?
Please help
 
Thats eazy! :)

Code:
Dim oConnection as New ADODB.Connection
Dim orsDebit as New ADODB.Recordset
Dim orsCredit as New ADODB.Recordset
Dim strQueryDebit as String
Dim strQueryCredit as String

oConnection.Open <Insert connectionstring to DB here>

strQueryDebit  = &quot;Select * From <Insert table name>&quot; & _
                 &quot;Where payment_type = 'Debit'&quot;
strQueryCredit = &quot;Select * From <Insert table name>&quot; & _
                 &quot;Where payment_type = 'Credit'&quot;

orsDebit.Open strQueryDebit, oConnection
orsCredit.Open strQueryCredit, oConnection

Good Luck!
-Mats Hulten
 
Thanks but that is the first step.
The main part is to have a third recordset which should contain both the fields(columns) i.e the one from orsDebit and the one from orsCredit.
How can this be done?
 
Code:
strQueryBoth = &quot;Select * From <Insert table name>&quot;

-Mats
 
thanks however what i need is to have amounts of different types i.e Debit and Credit to be in different columns/fields of the recordset.
this solution will give me all the data in the same field/column of the recordset
 
Hi,
SQL statement(on any RDBMS) can acheive this !!

Say your table actran has following fields

acno int
dbcrtype char(2)
amount money

dim rs as adodb.recordset
rs.open &quot;select acno,cramt=(case dbcrtype when &quot;CR&quot; then amount else 0 end),dbamt=(case dbcrtype when &quot;DB&quot; then amount else 0 end) from actran&quot;,etc....

...

Now you have both credits and debits in a single recordset..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top