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!
Thanks
--
Microsoft MVP - ASP/ASP.NET - 2004-2007
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
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?
In your hard-coded version, is there a period at the end of the data
source name?
Do a
response.write dbConnect
and compare it with the hard-coded string that works
--
HTH,
Bob Barrows
That is interesting ... I do not remember why that period was added.
I missed it because I was so sure that there had to be a problem with
the way the variable was being passed, but when I could not find a
problem I was thinking perhaps I was just mis-using the connection
object.
Thanks for the help.