M
Martin Eyles
I have just turned on option strict in ASP/VB.net. I started by happily
going through and setting up all of the Dim statements with As clauses, and
making my cast explicit. However, I have now got stuck on "late binding".
After reading that early binding is faster, I think that it would be best to
make everything early binding, but I can't work out how. have but a sample
of my database code below. Can anyone tell me how to fix it?
Thanks,
Martin
Public Sub aSub()
'Allocate Variables
Dim adCmdText, aConnectionString, SQL As String
Dim R, F, RecsAffected As Object
Dim conn As Object
'set connection string for login to database
aConnectionString = "Provider=SQLOLEDB;Data Source=server;" _
& "Database=aDataBase;UID=aUserID;PWD=aPassword"
conn = Server.CreateObject("ADODB.Connection") 'make connection
object
'send connection string to database, via oject
conn.ConnectionString = aConnectionString
'open the connection
conn.Open()
SQL = ("SELECT aValue FROM aTable WHERE theCondition='" + aCondition
+ "'")
R = conn.execute(SQL, RecsAffected, adCmdText)
For Each F In R.Fields
Response.Write("") 'do nothing
Next
While Not R.EOF
For Each F In R.Fields
aValue = F.Value
Next
R.MoveNext()
End While
conn.Close()
End Sub
going through and setting up all of the Dim statements with As clauses, and
making my cast explicit. However, I have now got stuck on "late binding".
After reading that early binding is faster, I think that it would be best to
make everything early binding, but I can't work out how. have but a sample
of my database code below. Can anyone tell me how to fix it?
Thanks,
Martin
Public Sub aSub()
'Allocate Variables
Dim adCmdText, aConnectionString, SQL As String
Dim R, F, RecsAffected As Object
Dim conn As Object
'set connection string for login to database
aConnectionString = "Provider=SQLOLEDB;Data Source=server;" _
& "Database=aDataBase;UID=aUserID;PWD=aPassword"
conn = Server.CreateObject("ADODB.Connection") 'make connection
object
'send connection string to database, via oject
conn.ConnectionString = aConnectionString
'open the connection
conn.Open()
SQL = ("SELECT aValue FROM aTable WHERE theCondition='" + aCondition
+ "'")
R = conn.execute(SQL, RecsAffected, adCmdText)
For Each F In R.Fields
Response.Write("") 'do nothing
Next
While Not R.EOF
For Each F In R.Fields
aValue = F.Value
Next
R.MoveNext()
End While
conn.Close()
End Sub