G
Guest
I am developing a Windows Form application that uses a SQL Server Express
2005 database, which it connects to using the AttachDBFilename property.
That works well when you know where your database file is.
I would like to run some queries against the master database in my SQL
Server Express 2005 instance, but there is no real way to tell where this
database resides on the system. I will be checking to see if any of my app
databases are connected, how big they are, etc. Although I can connect to my
specific database instances using AttachDBFilename, I can't seem to connect
to the master database on my local system with generic 'instance' connection
strings. I would think the query string would be similar to...
"Data Source=.\SQLEXPRESS;Integrated Security=True;User
Instance=False;initial catalog=master"
This connection string doesn't work using the following VB.NET code. It
always returns 'closed' as the status, because it never really connects.
_sSQLConnectionString = "Data Source=.\SQLEXPRESS;Integrated
Security=True;User Instance=False;initial catalog=master"
Dim oCon As New SqlClient.SqlConnection(_sSQLConnectionString)
Dim strSQLSearch As String
strSQLSearch = "Select * From master.dbo.sysdatabases"
Dim oDataAdapter As New SqlClient.SqlDataAdapter(strSQLSearch, oCon)
Dim oDataSet As New DataSet
oDataAdapter.Fill(oDataSet, strTableName)
oDataAdapter.Dispose()
oDataAdapter = Nothing
oCon.Close()
oCon.Dispose()
oCon = Nothing
I can't seem to figure out what connection string I need to connect to the
master database on my local SQLEXPRESS instance. I have verified that the
master DB does in fact exist, because it shows up in the SQL Express
Management Studio and SSEUtil. Any help would be greatly appreciated. Thanks.
2005 database, which it connects to using the AttachDBFilename property.
That works well when you know where your database file is.
I would like to run some queries against the master database in my SQL
Server Express 2005 instance, but there is no real way to tell where this
database resides on the system. I will be checking to see if any of my app
databases are connected, how big they are, etc. Although I can connect to my
specific database instances using AttachDBFilename, I can't seem to connect
to the master database on my local system with generic 'instance' connection
strings. I would think the query string would be similar to...
"Data Source=.\SQLEXPRESS;Integrated Security=True;User
Instance=False;initial catalog=master"
This connection string doesn't work using the following VB.NET code. It
always returns 'closed' as the status, because it never really connects.
_sSQLConnectionString = "Data Source=.\SQLEXPRESS;Integrated
Security=True;User Instance=False;initial catalog=master"
Dim oCon As New SqlClient.SqlConnection(_sSQLConnectionString)
Dim strSQLSearch As String
strSQLSearch = "Select * From master.dbo.sysdatabases"
Dim oDataAdapter As New SqlClient.SqlDataAdapter(strSQLSearch, oCon)
Dim oDataSet As New DataSet
oDataAdapter.Fill(oDataSet, strTableName)
oDataAdapter.Dispose()
oDataAdapter = Nothing
oCon.Close()
oCon.Dispose()
oCon = Nothing
I can't seem to figure out what connection string I need to connect to the
master database on my local SQLEXPRESS instance. I have verified that the
master DB does in fact exist, because it shows up in the SQL Express
Management Studio and SSEUtil. Any help would be greatly appreciated. Thanks.