Early Late binding

N

Nana & Sudha

Hi there
Can some body let me know if the following case is an Early or Late
binding :
Please tell me if the recordset object which I have used would be
categorised as Late or Early binding. Also if we reference any object type
from the IDE; will it fall in to the early binding even if we declare the
variable as an object and later set it to any particular object within the
code. Viceversa Is only using createobject or
getobject constitute for Late Binding. I have listed the code below for
which I refer to the ADO object from the IDE.

Your help would be much appreciated. Thx Very much in advance

Regards
Nana
'--------------------------------The Code Starts
here ---------------------------------------------------------

Function sqlsrvrConn(SQLserverName As String, SQLuserName As String,
SQLpassWord As String, _
SQLDatabaseName As String)

' Variable Declarations

Dim oconnStr As String
Dim oconn As New ADODB.Connection

'Dim ors As New ADODB.Recordset
Dim ors As Object

Dim rsSqlstr As String

Set ors = New ADODB.Recordset

' Initializations

oconnStr = "Provider=sqloledb;" & _
"Data Source=" & SQLserverName & ";" & _
"Initial Catalog=" & SQLDatabaseName & ";" & _
"user ID=" & SQLuserName & ";" & _
"password=" & SQLpassWord

rsSqlstr = "select * from authors"


With oconn
.ConnectionString = oconnStr
.Open
End With

ors.Open rsSqlstr, oconn, adOpenKeyset, adLockReadOnly
ors.MoveLast
Debug.Print ors.RecordCount

ors.MoveFirst
Do While Not ors.EOF
Debug.Print ors.Fields(1) & ors.Fields(2)
ors.MoveNext
Loop

End Function
' ------------------------------------------ The code Ends here
 
M

Michael Bauer

Hi Nana,

Late Binding means that the Objecttype is unknown at Compiletime. So the
Compiler can not check, if all the Methods you call are available. For
each call it has to check at Runtime - that´s very late and takes a
little more of time.

Dim obj as Object <- Late Binding

Dim obj as ADODB.Connection <- Early Binding

Get- and CreateObject don´t matter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top