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" ?
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.