← ClaudeAtlas

vb6-ado-late-bindinglisted

Applies the ADO late-binding pattern when writing or modifying database access code in Visual Basic 6, supporting both Microsoft SQL Server and PostgreSQL. Covers declaration as Object with CreateObject instantiation (never As ADODB.Connection or New ADODB.Recordset), ADO constants defined locally instead of referencing the type library, mandatory ConnectionTimeout before Open, the disconnected recordset pattern (CursorLocation client-side, then ActiveConnection = Nothing after Open), parameterized queries via ADODB.Command with Parameters.Append to prevent SQL injection and improve query plan caching, the AddADOParameter and SetADOCommandParameters helper functions that accumulate parameters in a Dictionary before applying them to a Command, multibank parameter naming (@param for MSSQL versus in_param/out_param for PostgreSQL) handled by SetParameter and GetParameter helpers, and structural SQL concatenation (table names, dynamic joins) versus value parameterization. Activates for any task involving ADODB, C
alexcassol/claude-vb6-skills · ★ 0 · API & Backend · score 70
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