Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieve DSN ADODB.Connection connectstring

    Hi,
    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;"
    objConnection.Open

    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.

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Daemonspyre,

    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.

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    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.

    http://msdn2.microsoft.com/en-us/library/ms681546.aspx
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •