Visual Basic Programming: Much Ado about ADO - Not Specifying the Library Being Referred To
(Page 2 of 5 )
Usually, this is how the ADO objects are declared in the General Declaration section:
Dim Con As Connection
Dim Com As Command
Dim Rst As Recordset
This works fine for a program that references just one data objects library (ADODB library in this instance), since you have selected just the ‘Microsoft ActiveX Data Objects 2.1 Library’ from the References menu. So when you say:
Dim Con As Connection
the complier creates a Connection object of ADODB library. But for an application that refers to more than one library that provides the data objects (for instance, the DAO architecture also has Connection, Command and Recordset objects), the habit of not specifying the appropriate library might lead to a messy code.
Here’s how an ADO object should ideally be declared and created:
Dim Con As ADODB.Connection
Set Con = New ADODB.Connection
Next: Improper Ways of Opening the Recordset Object >>
More Visual Basic.NET Articles
More By Maneesh Makheeja