Re: enumerating Sql Servers is wrong on some systems
- From: David Thielen <thielen@xxxxxxxxxxxxx>
- Date: Fri, 13 Mar 2009 15:47:30 -0600
Hi;
That is the code we call. The problem is it returns incorrect
information - returning "elbert" and not returning
"elbert\sqlexpress." How do we get the correct enumeration?
thanks - dave
On Thu, 12 Mar 2009 10:17:57 GMT, v-fathan@xxxxxxxxxxxxxxxxxxxx (Mark
Han[MSFT]) wrote:
Hi Dave,
Thank you for using Microsoft MSDN Managed Newsgroup. This is Mark Han,
again. I'm glad to assist you again.
From your description, I understand that the application doesn't return theright name of the SQL Server Express instance. If I have misunderstood,
please let me know.
Based on the current situation, I know that you install a SQL Server named
instance(SQLEXPRESS) and the application should return "elbert\SQLEXPRESS"
as the name. However the application just return "elbert" as the name of
the SQL Server.
Based on my research, using SqlClientFactory..::.CreateDataSourceEnumerator
Method might help to address your concern. The following example displays a
list of all available SQL Server data sources, using code that could
enumerate data sources for any provider.
Example
=========================
Visual Basic Copy Code
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Module Module1
Sub Main()
--List all SQL Server instances:
ListServers(SqlClientFactory.Instance)
Console.WriteLine()
Console.WriteLine("Press any key to continue.")
Console.ReadKey()
End Sub
Private Sub ListServers(ByVal factory As DbProviderFactory)
' This procedure is provider-agnostic, and can list
' instances of any provider's servers. Of course,
' not all providers can create a data source enumerator,
' so it's best to check the CanCreateDataSourceEnumerator property
' before attempting to list the data sources.
If factory.CanCreateDataSourceEnumerator Then
Dim instance As DbDataSourceEnumerator = _
factory.CreateDataSourceEnumerator
Dim table As System.Data.DataTable = instance.GetDataSources()
Dim row As DataRow
For Each row In table.Rows
Console.WriteLine("{0}\{1}", _
row("ServerName"), row("InstanceName"))
Next
End If
End Sub
End Module
Besides, there is an article to share with
you:http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlclientf
actory.createdatasourceenumerator.aspx
If tanything is unclear, please let me know.
Best regards,
Mark Han
Microsoft Online Community Support
===========================================================
Delighting our customers is our #1 priority. We welcome your
comments and suggestions about how we can improve the
support we provide to you. Please feel free to let my manager
know what you think of the level of service provided. You can
send feedback directly to my manager at: msdnmg@xxxxxxxxxxxxxx
===========================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or
a Microsoft Support Engineer within 2 business day is acceptable. Please
note that each follow up response may take approximately
2 business days as the support professional working with you may need
further investigation to reach the most efficient resolution.
The offering is not appropriate for situations that require urgent,
real-time or phone-based interactions. Issues of this nature are
best handled working with a dedicated Microsoft Support Engineer by
contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
============================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
=========================================================
david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com
Cubicle Wars - http://www.windwardreports.com/film.htm
.
- Follow-Ups:
- Re: enumerating Sql Servers is wrong on some systems
- From: Mark Han[MSFT]
- Re: enumerating Sql Servers is wrong on some systems
- References:
- enumerating Sql Servers is wrong on some systems
- From: David Thielen
- RE: enumerating Sql Servers is wrong on some systems
- From: Mark Han[MSFT]
- enumerating Sql Servers is wrong on some systems
- Prev by Date: Re: ms sql 2008 Install
- Next by Date: Re: ms sql 2008 Install
- Previous by thread: RE: enumerating Sql Servers is wrong on some systems
- Next by thread: Re: enumerating Sql Servers is wrong on some systems
- Index(es):
Relevant Pages
|
Loading