Reputation: 15686
I thought this would be easy but the following code gives...
Microsoft VBScript runtime error '800a01a8'
Object required: 'Application(...)'
/include/setup.asp, line 7
Function getConnectionString
Dim connectionString
Set connectionString = Application("ConnString")
If connectionString Is Nothing Then
Set connectionString = loadConnectionString
Application.Lock
Application("ConnString") = connectionString
Application.Unlock
End If
getConnectionString = connectionString
End Function
loadConnectionString
is another function.
How do I fix this?
Upvotes: 0
Views: 100
Reputation: 16681
The problem here is connectionString
variable is being treated as an Object
when it in fact contains a string
.
Set
should only be used to store Object
variables, this goes for Application("varname")
style variables as well. Remove the Is Nothing
check as this also refers to Object
variables and replace it with a Len(connectionString) < 1
check.
Function getConnectionString()
Dim connectionString
connectionString = Application("ConnString")
If Len(connectionString & "") < 1 Then
'loadConnectionString() should return a string not an Object
'may need to be amended.
connectionString = loadConnectionString()
Application.Lock
Application("ConnString") = connectionString
Application.Unlock
End If
getConnectionString = connectionString
End Function
Upvotes: 1