Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 sql express

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-02-12 : 10:05:46
Sunny writes "Hello:

I've been struggling with this for a few days and can't seem to find the answer.

I have a vb6 exe that needs to connect to an instance of sql express. The instance may or may not be running and the database will not be attached if the instance is not running.

I'm able to connect with my connection string to sql express:

Set cn = New ADODB.Connection
cn.ConnectionString = "Provider= SQLOLEDB; Data Source=.\SQLEXPRESS; Integrated Security=SSPI;Connect Timeout=30"

and the get user instance name:

'Get the user instance name
strSQL = "SELECT owning_principal_name, instance_pipe_name From sys.dm_os_child_instances"


but how do I query tables within the user instance? I've looked at connectionstrings.com and various other sources, but I'm lost. Any help is appreciated."

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-12 : 10:54:50
you start in the default database for the user that's connecting.
so you'd have a connection string per database:
you have to add Default Catalog=YourDbName to your connection string



Go with the flow & have fun! Else fight the flow
blog thingie: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -