Re: dynamic connection string
- From: coolnamewithheld <NTuser_Man@xxxxxxx>
- Date: Tue, 28 Jul 2009 11:26:04 -0700 (PDT)
On Jul 27, 5:42 pm, "Bob Barrows" <reb01...@xxxxxxxxxxxxxxx> wrote:
coolnamewithheld wrote:
How do I create a dynamicconnectionstringwith the name of the
data source being passed as a variable.
The way I want this to work is the server name is passed from a
classic asp page as a input from a form:
srvName=trim(Request.Form("srvName"))
Next I generate a connection string, something like
dbConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=sa;password=password;Initial Catalog=master;Data
Source="&srvName&"."
Then I go on to use the connection string in an ADODB.Connection
object.
It has been quite a while since I worked with classic asp, so this
might just be a bad idea .. :) Please give me a clue if you can!
Aside from the use of the sa account, you have it perfect.
Never use the sa account in application code. SA is for Systaem
Administration, and as such, in the wrong hands, could be used to wreak
havoc on a server and network. Always create a limited-permissions account
for use in applications, only granting the permissions needed to perform the
functions required by the application.
The sa account is just for the example.
The problem I am having is the variable passed using a form on a
previous page, and collected with this:
srvName=""
srvName=trim(Request.Form("srvName"))
I verify that the value of the variable is correct using a print
statement:
response.write("<BR>srvName="&srvName)
response.end
and then render comments when I want to run the page.
However, the value of the variable is not recognized in the
ADODB.Connection object.
When I execute using this connection string:
dbConnect = "Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=sa;password=password;Initial Catalog=master;Data
Source="&srvName&"."
The connection fails.
If i replace the variable being supplied to Data Source with a hard
coded server name, the connection string does work.
This will not work for me .. I need to have a dynamic connection
string build from user choices. How does one get that to work?
.
- Follow-Ups:
- Re: dynamic connection string
- From: Bob Barrows
- Re: dynamic connection string
- References:
- dynamic connection string
- From: coolnamewithheld
- Re: dynamic connection string
- From: Bob Barrows
- dynamic connection string
- Prev by Date: Re: storage of orders
- Next by Date: Re: dynamic connection string
- Previous by thread: Re: dynamic connection string
- Next by thread: Re: dynamic connection string
- Index(es):
Relevant Pages
|