View Full Version : Retrieve DSN ADODB.Connection connectstring

06-29-2007, 10:09 PM
I like to know if there’s way to retrieve the connect string from an opened ADODB.Connection established via system DSN. For example, I first declare/open my connection like this:

Dim objConnection
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString = "DSN=MYDB;"

Later on, I need the username/password/DB name for some other external calls to execute a dos batch script calls sql*plus with some sql scripts. How can i retrieve the username/password/DB name that's setup in the system DSN (MYDB)?

Any idea/suggestion is greatly appreciated.

06-30-2007, 01:21 AM
Since the DSN operates outside the web connection (i.e. through an ODBC driver), I am not sure that you can do that (doesn't mean that you cannot, I just don't know if you can).

You can use session variables to push that information, but that won't necessarily solve your problem.

You may need to use the Driver Connection String rather than the DSN if you want to do this progmatically.

06-30-2007, 01:27 AM

Thanks for your reply. Actually, the main idea is to manage the connection strings via system DSN so when the information is updated, only one place need to be maintained. Of course one can make the case for that to be in the connect string in ASP, but in this case, i like to keep that "one" place in DSN if at all possible.

Thanks, nonetheless.

06-30-2007, 01:39 AM
With all the sites I administer, I know EXACTLY what you mean.

However, you may not be able to do this. DSNs don't operate within IIS, which means that ASP and IIS don't have access to this without specifically telling it to (i.e. Server.CreateObject).

Here's some more data for you on the Connection properties, but I have already scoured it and didn't find what you were looking for. But, it doesn't hurt to have 2 (or more) sets of eyes on it.