Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Find SQL Location

DroopyADroopyA Member Posts: 175
Ok, I'm trying to detach a SQL database though VB code. However, to do this I need to connect to SQL server. But I can't connect to my softwares database because then I won't be able to detach a database that's in use. So I need to connect to SQL servers default Master Database.

The problem is that the user may have installed SQL server in a directory other then the default specified path. So before I can connect to the database, I need to figure out where it is (the Master.mdf file path) all through Visual Basic.

I don't need the code, but more of the location of such information. I searched the registry but couldn't find anything. Is it in the registry and I just missed it? Any other ideas?


Comments

  • WolfsbaneWolfsbane Member Posts: 12
    I may be wrong in this but you do not need to know the loaction of the Master database. You use a connection string and connect to the server with master being the database of choice then issue your disconnect command on the database you want to disconnect.

    : Ok, I'm trying to detach a SQL database though VB code. However, to do this I need to connect to SQL server. But I can't connect to my softwares database because then I won't be able to detach a database that's in use. So I need to connect to SQL servers default Master Database.
    :
    : The problem is that the user may have installed SQL server in a directory other then the default specified path. So before I can connect to the database, I need to figure out where it is (the Master.mdf file path) all through Visual Basic.
    :
    : I don't need the code, but more of the location of such information. I searched the registry but couldn't find anything. Is it in the registry and I just missed it? Any other ideas?
    :
    :
    :

Sign In or Register to comment.