Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setrting the connection to DB in the global.asa

Status
Not open for further replies.

DREAMaker

Programmer
Oct 7, 2000
7
IT
I know how to set a DSN conn to DB.
But what I ignore is how to set it in global.asa and then call it in my page...

Can you help me in do this?

(Please forgive my not very good english...)
[sig][/sig]
 
corrected your english:
But what I don't understand is how to set it in a global.asp and then call it in my page...

You might use an Include
Here is an Example:

<html><head>
<TITLE>includedynamic.asp</TITLE>
</head><body bgcolor=&quot;#FFFFFF&quot;>
<%
whichfile=&quot;bookscifi.asp&quot;
Call ReadDisplayFile(whichfile)
response.write &quot;<hr>&quot;

whichfile=&quot;bookhorror.asp&quot;
Call ReadDisplayFile(whichfile)
response.write &quot;<hr>&quot;


whichfile=&quot;/learn/test/bookmarketing.asp&quot;
Call ReadDisplayFile(whichfile)
response.write &quot;<hr>&quot;
%>

</body></html>
<%
SUB ReadDisplayFile(FileToRead)
whichfile=server.mappath(FileToRead)
Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set thisfile = fs.OpenTextFile(whichfile, 1, False)
tempSTR=thisfile.readall
response.write tempSTR
thisfile.Close
set thisfile=nothing
set fs=nothing
END SUB
%>


[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
When you use Visual Interdev it constructs the connection in the global.asa for you. Here is what it put in mine:
Code:
	'==Visual InterDev Generated - startspan==
	'--Project Data Connection
		Application(&quot;NetworkDB_ConnectionString&quot;) = &quot;Provider=SQLOLEDB.1;Persist Security Info=False;User ID=<username for development here>;Initial Catalog=Network;Data Source=<servername here>;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=<SERVERNAME HERE>;&quot;
		Application(&quot;NetworkDB_ConnectionTimeout&quot;) = 15
		Application(&quot;NetworkDB_CommandTimeout&quot;) = 30
		Application(&quot;NetworkDB_CursorLocation&quot;) = 3
		Application(&quot;NetworkDB_RuntimeUserName&quot;) = &quot;<USERNAME RUNTIME HERE>&quot;
		Application(&quot;NetworkDB_RuntimePassword&quot;) = &quot;<RUNTIME PASSWORD>&quot;
	'-- Project Data Environment
		Set DE = Server.CreateObject(&quot;DERuntime.DERuntime&quot;)
		Application(&quot;DE&quot;) = DE.Load(Server.MapPath(&quot;Global.ASA&quot;), &quot;_private/DataEnvironment/DataEnvironment.asa&quot;)
	'==Visual InterDev Generated - endspan==

Replace any of the values you need to replace in particular the things I put into <>. Now admittedly I am not that great with all the connection stuff in ASP since I have been utilizing the tools Interdev provides so I don't know if all of this is necessary, or if it is well done. I don't think the actual connection is made here but the stuff to make the connections is all set up. I know that I used the connection string in the one connection that I needed to create. [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Once again, having ADO objects at the application and session level is not recommended (even microsoft advises against this at their top-25-asp-tips page) because of how the underlying threading model works for asp. Setting the connection string at this level is probably OK however.

You can read more about this at:

[sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top