View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
onedaywhen onedaywhen is offline
external usenet poster
 
Posts: 459
Default Microsoft ADO Ext. 2.5 vs. 2.6 for DDL...

In a nutshell, to change from early to late bound:

• replace variables dim'ed with class name with Object type;
• replace instantiation (New keyword) with CreateObject;
• replace enumerations with constants.

Here's some example code. The two procedures are the same but for binding:

Sub TestEarlyBound()

Dim oConn As ADODB.Connection
Dim oRs As ADODB.Recordset
Dim strSql As String

Set oConn = New ADODB.Connection

With oConn
.CursorLocation = adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPATH
.Open
End With

strSql = "SELECT RefID, Surname" & _
" FROM PersonalDetails"

Set oRs = oConn.Execute(strSql)

' <code

oRs.Close
oConn.Close

End Sub

Sub TestLateBound()

Dim oConn As Object
Dim oRs As Object
Dim strSql As String

Set oConn = CreateObject("ADODB.Connection")

With oConn
.CursorLocation = 3 ' adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPATH
.Open
End With

strSql = "SELECT RefID, Surname" & _
" FROM PersonalDetails"

Set oRs = oConn.Execute(strSql)

' <code

oRs.Close
oConn.Close

End Sub

--

"Derek" wrote in message ...
Thanks for all of you. How to use the late binding in
detailed steps?


-----Original Message-----
I disagree. I think late binding *is* the best solution.

--