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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between using Recordset and ADODB.Recordset

Status
Not open for further replies.

damonh78

Programmer
Jul 28, 2005
44
IE
Hi,

When accessing a DB using ADO, whats the difference between using the AODB prefix and not using it, for example setting a variable as "Dim rs as Recordset" and "Dim rs as ADODB.Recordset" ?

Thanks,

John
 
depends on your references.

If you have declared references to two or more components each containing a recordset object, then you may not be refering to the one you wish.

So best is to ALWAYS reference the correct object, e.g. ADODB.recordset on this case.

For maintenance purposes it is always easier if you have the full reference, as that way the developer knows immediatelly which object model he is working with.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
As well as the reasons Frederico gives, a reason that people generally specify ADODB.Recordset is because DAO also has a Recordset object, so what was always a good habit became more important. If VB thinks it's using a DAO Recordset and you're writing for an ADO Recordset, the program will hang.

When you declare an object, VB will look through all of its references' type libraries until it finds the declared class name, starting at the top of the list and moving down. So, say you first set a reference to DAO, and then another to ADO. You then declare a Recordset object. If you try to instantiate this object in the ADO manner (set rs = new recordset), the program will hang, because DAO recordsets can't be created directly. If ADO is higher than DAO in the reference list, the program will not hang. That's why there are those arrows to move references up and down.

All that said, it's safer and more efficient (VB doesn't have to look through all the references until it finds the right one, it can go straight to the one specified) to specify the name, as well as making life easier for developers.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top