F
Faisal
Hi.
I'm in the process of moving an application from ASP to ASP.NET, & I'm
writing in VB, using VS.NET. I'm new to the .NET framework & have a
basic question regarding static objects defined in global.asax.
In the global.asax file I want to declare some static objects (like an
ADODB.Connection, an ADODB.Recordset, a
Scripting.FileSystemObject...), and so I've done so using object tags.
For example I have:
<object runat=server id=DBConn progid="ADODB.Connection
scope=session />
So this should add DBConn to the StaticObjects collection in
HttpApplicationState, and should add DBConn to the namespace of all
the other aspx pages in the application. My problem, though, is when
I refer to any of these static objects in later pages I get build
errors. For example in the code behind page, WebForm1.aspx.vb, if I
write a statement like adcn.Open(...), I get the error: Name 'adcn' is
not declared. Am I making a mistake somewhere here? Is there
something wrong with my syntax? Or do I need to import any specific
files (so far WebForm1.aspx.vb imports ADODB, Scripting, System,
System.Web, & System.Web.UI.HtmlControls)?
I've tried instead doing things like: Application("adcn"), but I don't
think I should need to do this as adcn should already be present in
the namespace. I've alternatively tried to declare the variables
inside the sub Appliation_Start instead of using <object> tags.
However, then I try that like Glboal.adcn.open(...) I get errors
saying something like I must create an object reference first.
I think this must be a trivial question, but I can't seem to find the
answer in my searches online. Any help would be appreciated.
Thanks in advance,
Faisal
I'm in the process of moving an application from ASP to ASP.NET, & I'm
writing in VB, using VS.NET. I'm new to the .NET framework & have a
basic question regarding static objects defined in global.asax.
In the global.asax file I want to declare some static objects (like an
ADODB.Connection, an ADODB.Recordset, a
Scripting.FileSystemObject...), and so I've done so using object tags.
For example I have:
<object runat=server id=DBConn progid="ADODB.Connection
scope=session />
So this should add DBConn to the StaticObjects collection in
HttpApplicationState, and should add DBConn to the namespace of all
the other aspx pages in the application. My problem, though, is when
I refer to any of these static objects in later pages I get build
errors. For example in the code behind page, WebForm1.aspx.vb, if I
write a statement like adcn.Open(...), I get the error: Name 'adcn' is
not declared. Am I making a mistake somewhere here? Is there
something wrong with my syntax? Or do I need to import any specific
files (so far WebForm1.aspx.vb imports ADODB, Scripting, System,
System.Web, & System.Web.UI.HtmlControls)?
I've tried instead doing things like: Application("adcn"), but I don't
think I should need to do this as adcn should already be present in
the namespace. I've alternatively tried to declare the variables
inside the sub Appliation_Start instead of using <object> tags.
However, then I try that like Glboal.adcn.open(...) I get errors
saying something like I must create an object reference first.
I think this must be a trivial question, but I can't seem to find the
answer in my searches online. Any help would be appreciated.
Thanks in advance,
Faisal