vb6-ado-late-bindinglisted
Install: claude install-skill alexcassol/claude-vb6-skills
# ADO Late Binding — VB6
ADO is accessed via **late binding** to avoid version-locking the MDAC stack on
client machines. No reference to "Microsoft ActiveX Data Objects x.x Library"
is added to the project. Both Microsoft SQL Server and PostgreSQL are
supported through the same ADO surface, with small naming differences in
parameter handling.
## 1. Declaration and instantiation
```vb
' Declarations — always As Object
Private mobjCnn As Object
Private mrsCustomers As Object
' Instantiation — always CreateObject
Set mobjCnn = CreateObject("ADODB.Connection")
Set objRs = CreateObject("ADODB.Recordset")
Set objCmd = CreateObject("ADODB.Command")
```
**Never:**
- `Dim cnn As ADODB.Connection`
- `Dim rs As ADODB.Recordset`
- `Set rs = New ADODB.Recordset`
- Adding a reference to the ADO type library
**Rationale:** different Windows versions ship different MDAC versions. Early
binding to a specific type library version causes "ActiveX component can't
create object" or "type mismatch" errors when the client has a different
version installed. Late binding works against whatever ADO is present.
## 2. ADO constants — defined locally
Because the type library is not referenced, ADO constants must be defined as
local constants or used as literals. The recommended approach for new code is
to declare them at the top of any module that uses ADO, or in a shared
`modADOConstants.bas`.
```vb
Option Explicit
' Command types
Private Const adCmdText As Long = 1
Private Const adC