Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 12th, 2006, 04:32 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP Database Connection

HI Guyz

I am New in ASP. I have a Database for which the user name is "da" and password is "hellothere". I have the following code which establishes the connection with remote server. But I want to write a separate ASP file contaiting this lines so that when I change user name and password, I just need to change in that file only, not in every ASP pages. Any Help would be highly appreciated.

<%
dim Constring1
Constring1 = "Provider=SQLOLEDB;Server=139.78.185.223;Database= rddata;UID=da;PWD=hellothere;"
mysql = "SELECT DISTINCT TOP 100 PERCENT CountyName, CountyFIPS FROM dbo.tblCounties WHERE (StateFIPS = '40') ORDER BY CountyName"
Set con1 = Server.CreateObject("ADODB.Connection")
con1.Open(Constring1)
'con.Source = "SELECT * FROM dbo.tblCensus_CO_Fact"
Set RS1 = Server.CreateObject("ADODB.Recordset")
RS1.Open mysql,con1
RS1.PageSize = 10
%>

Shaikot
 
Old June 12th, 2006, 07:47 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

You can put your connection string into the global.asa file like this:

Sub Application_OnStart
Application("Constring1") = "Provider=SQLOLEDB;Server=139.78.185.223;Database= rddata;UID=da;PWD=hellothere;"
end sub

Then you can access it throughout your app like this:

con1.Open Application("Constring1")








Similar Threads
Thread Thread Starter Forum Replies Last Post
another database connection question! asp and mysq fogofogo Classic ASP Professional 2 December 2nd, 2005 08:20 AM
Database Connection Problem with ASP.NET fukai100 SQL Server ASP 1 August 12th, 2004 07:37 PM
connection to Database. ASP, Dreamweaver, Access CrazyCanuck Classic ASP Basics 2 July 4th, 2004 09:12 PM
ASP.NET database connection MySQL socoolbrewster ASP.NET 1.0 and 1.1 Basics 3 November 21st, 2003 07:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.