|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
The object here is that I want to get the database connection string variable from the global.asa onstart method for ASPs using VBScript or JavaScript as their primary language. The problem ASP is using JAVASCRIPT as its scripting engine main language.
I have a situation where I'm making changes to an application and for whatever odd reason the developer who initially wrote a particular ASP made one of the pages set like this: --------ASP page code --------------------- <%@ language="JavaScript" %> var oConn; oConn = new ActiveXObject( "ADODB.Connection" ); //oConn.ConnectionString = application("app_cwr_con"); oConn.Open(application("app_cwr_con")); // does not work; OBJECT EXPECTED error in runtime //oConn.Open ( "Provider=OraOLEDB.Oracle.1;Password=cen3rep;Persis t Security Info=True;User ID=cen3rep;Data Source=edm.world;DistribTx=0" ); <-- Works, but isn't what I want. ------------------------------------------------- --------------Global.asa page code---------------------- <SCRIPT LANGUAGE=VBScript RUNAT=Server> 'Application_OnStart Runs once when the first page of your application is run for the first time by any user sub application_onstart application("app_cwr_con") = "Provider=OraOLEDB.Oracle.1;Password=passwordHere;P ersist Security Info=True;User ID=userNameHere;Data Source=dbHere.world;DistribTx=0 " end sub </SCRIPT> <head><title>Web Settings for Active Server Pages</title></head> -------------------------------------------------------- When using application("app_cwr_con") in an ASP that uses VBScript as its primary language the "application("app_cwr_con");" is recognized fine and the connection string does WORK and is picked up. When using that same syntax in an ASP that uses JavaScript as its primary language it does not work. Hypothesizing: Do I need to add another set of script tags to the global.asa defined for use with JavaScript? Is this why my JavaScript ASPs can't see the app_cwr_con variable? Anyone have documentation on JavaScript and trying to access a database syntax? JScript syntax even? I'm thinking even though the page is told JavaScript in the directive at top that its still using a JScript engine. Need help soon. On a deadline. Thanks ahead of time to all |
|
#2
|
||||
|
||||
|
Hmm - it would appear from this that ASP and server-side JS don't share the same namespace. You could try a little test by placing some JS and ASP code on the one page and see if you can access each others variables....
Regardless, a way around your problem is to place the connection string code in an include file (using a JS var), and just link to it that way (<!-- #INCLUDE FILE="connstr.asp" -->), rather than using an application object. This method will consume less memory too. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > JavaScript ASP to pull ConnStr from Global.asa |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|