SQLDatasourceEnumerator

  • Thread starter Thread starter Dom
  • Start date Start date
D

Dom

I use this class to find all the SQL Servers on the network, and it
works fine. The problem is this: For the server name, I get, eg,
"CASSIUS", I do not get "CASSIUS\SQLEXPRESS". When I use this short
name in the ConnectionString for SQLConnection.Open(), the Open-method
fails, presumably because it needs the full name. In fact, when I
hoke it up in the debugger, and use the full name, it works fine.

Isn't there something wrong here? Shouldn't the Enumerator class
return a value that gets plugged into the ConnectionString?

Dom
 
Dom,

Is the SQL Server Browser service running? If not, then you might not
get the instance name on the server. See the MSDN documentation titled
"Enumerating Instances of SQL Server", located at:

http://msdn2.microsoft.com/en-us/library/a6t1z9x2(vs.80).aspx

Specifically, check out the section titled "Enumeration Limitations".

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I use this class to find all the SQL Servers on the network, and it
works fine. The problem is this: For the server name, I get, eg,
"CASSIUS", I do not get "CASSIUS\SQLEXPRESS". When I use this short
name in the ConnectionString for SQLConnection.Open(), the Open-method
fails, presumably because it needs the full name. In fact, when I
hoke it up in the debugger, and use the full name, it works fine.
Isn't there something wrong here? Shouldn't the Enumerator class
return a value that gets plugged into the ConnectionString?

You're right that I didn't have the browser running, but even after I
turn it on I get nothing for the InstanceName column in
SqlDatasourceEnumerator. Is that the way it works? In "CASSIUS
\SQLEXPRESS", is CASSIUS the server name, and SQLExpress the instance
name?

Any other ideas? Anyone?
 
Dom,

Is the SQL Server Browser service running? If not, then you might not
get the instance name on the server. See the MSDN documentation titled
"Enumerating Instances of SQL Server", located at:

http://msdn2.microsoft.com/en-us/library/a6t1z9x2(vs.80).aspx

Specifically, check out the section titled "Enumeration Limitations".

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)


I use this class to find all the SQL Servers on the network, and it
works fine. The problem is this: For the server name, I get, eg,
"CASSIUS", I do not get "CASSIUS\SQLEXPRESS". When I use this short
name in the ConnectionString for SQLConnection.Open(), the Open-method
fails, presumably because it needs the full name. In fact, when I
hoke it up in the debugger, and use the full name, it works fine.
Isn't there something wrong here? Shouldn't the Enumerator class
return a value that gets plugged into the ConnectionString?

I've discovered that the InstanceName will return a type DBNull if the
instance is the default instance. How do I use this information?
That is, how do I use the default name in the connection string?

Dom
 
Back
Top