Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

Finding Instances of SQL Server for DropDownList

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michael - 15 Jan 2006 13:49 GMT
I'm writnng a support routine which helps log on to instances of SQL Server.
Currently I populate a DropDownList with known names of SQL Server Instances.
What I would like is a simple way (if possible) to populate this control by
shouting into the network and listening for replies saying "I'm a SQL Server
instance, these are my characteristics. Here I am!". Sort of like getting a
directory of files but of SQL server names instead. Am I dreaming?

Signature

Michael Hockstein

William (Bill) Vaughn - 15 Jan 2006 19:47 GMT
Nope, you're not dreaming. In the olden days we used NetServeEnum(2) to
enumerate the servers, but in the 2.0 Framework you can call a
GetProviderFactory class (or somesuch) to do so.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> I'm writnng a support routine which helps log on to instances of SQL
> Server.
[quoted text clipped - 7 lines]
> a
> directory of files but of SQL server names instead. Am I dreaming?
michael - 15 Jan 2006 22:31 GMT
Bill,

Can't seem to find the reference you mentioned. Very excited to find and
explore it though.

Signature

Michael Hockstein

> Nope, you're not dreaming. In the olden days we used NetServeEnum(2) to
> enumerate the servers, but in the 2.0 Framework you can call a
[quoted text clipped - 11 lines]
> > a
> > directory of files but of SQL server names instead. Am I dreaming?
William (Bill) Vaughn - 16 Jan 2006 01:30 GMT
How's this? It's from my "Connecting" talk and part of my ADO.NET 2.0 VSLive
Workshop to be done in SFO in February.

Private Sub ReturnListOfServerInstances(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
       Dim drProvider As DataRow =
DbProviderFactories.GetFactoryClasses.Rows(0) ' To make sure object is
instantiated
       Try
           Me.Cursor = Cursors.WaitCursor
           ' DbProviderFactories is a new class for ADO 2.0
           ' GetFactoryClasses is a new method for ADO 2.0
           tblProviders = DbProviderFactories.GetFactoryClasses()
           For Each drProvider In tblProviders.Rows
               Dim factory As DbProviderFactory =
DbProviderFactories.GetFactory(drProvider)
               Dim dsE As DbDataSourceEnumerator =
factory.CreateDataSourceEnumerator()
               If dsE Is Nothing Then
               Else
                   DataGridView1.DataSource = dsE.GetDataSources()
               End If
           Next drProvider
       Catch exCE As System.Configuration.ConfigurationException
           MsgBox("The " & drProvider(0).ToString & " could not be
loaded.")
       Catch ex As Exception
           MsgBox(ex.ToString)
       Finally
           Me.Cursor = Cursors.Default
       End Try
   End Sub

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Bill,
>
[quoted text clipped - 18 lines]
>> > a
>> > directory of files but of SQL server names instead. Am I dreaming?
michael - 16 Jan 2006 02:22 GMT
Let me give the snippet a whirl. Thanks for the help. I'll let you know how
it goes. What conference in SFO in February?

Signature

Michael Hockstein

> How's this? It's from my "Connecting" talk and part of my ADO.NET 2.0 VSLive
> Workshop to be done in SFO in February.
[quoted text clipped - 51 lines]
> >> > a
> >> > directory of files but of SQL server names instead. Am I dreaming?
William (Bill) Vaughn - 16 Jan 2006 03:19 GMT
VSLive. I hope it works.

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Let me give the snippet a whirl. Thanks for the help. I'll let you know
> how
[quoted text clipped - 60 lines]
>> >> > a
>> >> > directory of files but of SQL server names instead. Am I dreaming?
michael - 16 Jan 2006 17:26 GMT
Works great. I noticed that if I have my VPN open to another location that
also has SQL servers, the routine will not return instances on the other side
of the VPN, just my local network. The code as it is however is vastly better
than what I had before.

Signature

Michael Hockstein

> VSLive. I hope it works.
>
[quoted text clipped - 62 lines]
> >> >> > a
> >> >> > directory of files but of SQL server names instead. Am I dreaming?
W.G. Ryan eMVP - 15 Jan 2006 23:44 GMT
http://www.codeproject.com/cs/database/LocatingSql.asp
http://www.codeproject.com/cs/database/SubmitSQLInfoEnumerator.asp
> I'm writnng a support routine which helps log on to instances of SQL
> Server.
[quoted text clipped - 7 lines]
> a
> directory of files but of SQL server names instead. Am I dreaming?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.