Click to See Complete Forum and Search --> : Global.asa problem


Kuriyama
04-01-2008, 10:19 AM
I'm attempting to create instantiate a class I created in the global.asa so that I can use it everyone on my site.

When I attempt to use the object on my pages, I get the following error

Microsoft VBScript runtime error '800a01a8'

Object required: ''

/dbBeantest.asp, line 3

Here is a snippet from global.asa
Please note that this is line 1-4 of my global.asa

<!-- #include virtual="dbBean.asp" -->
<script language="vbscript" runat="server">
dim objBean
set objBean = New dbBean
..
..
.


Here is a snippet from the test page.


<%
Response.write objBean.commandText
. . .

and finally. . here is the class I created.



Class dbBean
'''''''''''
' Variables
'''''''''''
private objCommand
private objRecordSet
private strSQL

'''''''''''''
' Constructor
'''''''''''''
private sub Class_Initialize()
set objCommand = Server.CreateObject("ADODB.Command")
set objRecordSet = Server.CreateObject("ADODB.RecordSet")
strSQL = "aasdf"
end sub

''''''''''''''''''''''''''''''''''
' Set strSQL to a new query string
' We escape apostrophies here.
''''''''''''''''''''''''''''''''''
Public Property Let commandText(strNewQS)
if strNewQS <> "" and NOT isNull(strNewQS) then
strSQL = Replace(strNewQS, "'", "''")
else
strSQL = ""
end if
End Property

Public Property Get commandText()
commandText = strSQL
End Property

''''''''''''
' Destructor
''''''''''''
private sub Class_Terminate()
set objCommand = nothing
set objRecordSet = nothing
end sub

End Class


Any idea what I'm doing wrong here?

WebDevJohnA
04-01-2008, 12:59 PM
I believe this is a threading issue, and you can solve it by lodging the object in either a Session or Application variable. For example,

Set Application("xBean") = New dbBean

and then, in the test page, reference it thus:

Dim objBean
Set objBean = Application("xBean")

and then you can

Response.write objBean.commandText