Home All Groups Group Topic Archive Search About

Finding Instances of SQL Server for DropDownList

Author
15 Jan 2006 1:49 PM
michael
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?


--
Michael Hockstein
Author
15 Jan 2006 7:47 PM
William (Bill) Vaughn
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.

--
____________________________________
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.
__________________________________

Show quoteHide quote
"michael" <howlinghound@nospam.nospam> wrote in message
news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
> 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?
>
>
> --
> Michael Hockstein
Are all your drivers up to date? click for free checkup

Author
15 Jan 2006 10:31 PM
michael
Bill,

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


--
Michael Hockstein


Show quoteHide quote
"William (Bill) Vaughn" wrote:

> 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.
>
> --
> ____________________________________
> 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.
> __________________________________
>
> "michael" <howlinghound@nospam.nospam> wrote in message
> news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
> > 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?
> >
> >
> > --
> > Michael Hockstein
>
>
>
Author
16 Jan 2006 1:30 AM
William (Bill) Vaughn
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

--
____________________________________
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.
__________________________________

Show quoteHide quote
"michael" <howlinghound@nospam.nospam> wrote in message
news:A49E7EE8-803E-44A7-B900-C46D11F5A169@microsoft.com...
> Bill,
>
> Can't seem to find the reference you mentioned. Very excited to find and
> explore it though.
>
>
> --
> Michael Hockstein
>
>
> "William (Bill) Vaughn" wrote:
>
>> 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.
>>
>> --
>> ____________________________________
>> 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.
>> __________________________________
>>
>> "michael" <howlinghound@nospam.nospam> wrote in message
>> news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
>> > 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?
>> >
>> >
>> > --
>> > Michael Hockstein
>>
>>
>>
Author
16 Jan 2006 2:22 AM
michael
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?

--
Michael Hockstein


Show quoteHide quote
"William (Bill) Vaughn" wrote:

> 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
>
> --
> ____________________________________
> 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.
> __________________________________
>
> "michael" <howlinghound@nospam.nospam> wrote in message
> news:A49E7EE8-803E-44A7-B900-C46D11F5A169@microsoft.com...
> > Bill,
> >
> > Can't seem to find the reference you mentioned. Very excited to find and
> > explore it though.
> >
> >
> > --
> > Michael Hockstein
> >
> >
> > "William (Bill) Vaughn" wrote:
> >
> >> 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.
> >>
> >> --
> >> ____________________________________
> >> 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.
> >> __________________________________
> >>
> >> "michael" <howlinghound@nospam.nospam> wrote in message
> >> news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
> >> > 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?
> >> >
> >> >
> >> > --
> >> > Michael Hockstein
> >>
> >>
> >>
>
>
>
Author
16 Jan 2006 3:19 AM
William (Bill) Vaughn
VSLive. I hope it works.


--
____________________________________
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.
__________________________________

Show quoteHide quote
"michael" <howlinghound@nospam.nospam> wrote in message
news:42B959EE-00FA-4F2E-A572-CD38500E508B@microsoft.com...
> 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?
>
> --
> Michael Hockstein
>
>
> "William (Bill) Vaughn" wrote:
>
>> 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
>>
>> --
>> ____________________________________
>> 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.
>> __________________________________
>>
>> "michael" <howlinghound@nospam.nospam> wrote in message
>> news:A49E7EE8-803E-44A7-B900-C46D11F5A169@microsoft.com...
>> > Bill,
>> >
>> > Can't seem to find the reference you mentioned. Very excited to find
>> > and
>> > explore it though.
>> >
>> >
>> > --
>> > Michael Hockstein
>> >
>> >
>> > "William (Bill) Vaughn" wrote:
>> >
>> >> 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.
>> >>
>> >> --
>> >> ____________________________________
>> >> 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.
>> >> __________________________________
>> >>
>> >> "michael" <howlinghound@nospam.nospam> wrote in message
>> >> news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
>> >> > 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?
>> >> >
>> >> >
>> >> > --
>> >> > Michael Hockstein
>> >>
>> >>
>> >>
>>
>>
>>
Author
16 Jan 2006 5:26 PM
michael
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.

--
Michael Hockstein


Show quoteHide quote
"William (Bill) Vaughn" wrote:

> VSLive. I hope it works.
>
>
> --
> ____________________________________
> 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.
> __________________________________
>
> "michael" <howlinghound@nospam.nospam> wrote in message
> news:42B959EE-00FA-4F2E-A572-CD38500E508B@microsoft.com...
> > 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?
> >
> > --
> > Michael Hockstein
> >
> >
> > "William (Bill) Vaughn" wrote:
> >
> >> 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
> >>
> >> --
> >> ____________________________________
> >> 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.
> >> __________________________________
> >>
> >> "michael" <howlinghound@nospam.nospam> wrote in message
> >> news:A49E7EE8-803E-44A7-B900-C46D11F5A169@microsoft.com...
> >> > Bill,
> >> >
> >> > Can't seem to find the reference you mentioned. Very excited to find
> >> > and
> >> > explore it though.
> >> >
> >> >
> >> > --
> >> > Michael Hockstein
> >> >
> >> >
> >> > "William (Bill) Vaughn" wrote:
> >> >
> >> >> 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.
> >> >>
> >> >> --
> >> >> ____________________________________
> >> >> 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.
> >> >> __________________________________
> >> >>
> >> >> "michael" <howlinghound@nospam.nospam> wrote in message
> >> >> news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
> >> >> > 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?
> >> >> >
> >> >> >
> >> >> > --
> >> >> > Michael Hockstein
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Author
15 Jan 2006 11:44 PM
W.G. Ryan eMVP
http://www.codeproject.com/cs/database/LocatingSql.asp
http://www.codeproject.com/cs/database/SubmitSQLInfoEnumerator.asp
Show quote Hide quote
"michael" <howlinghound@nospam.nospam> wrote in message
news:548AF089-D3AD-44D5-9C9D-20484311F872@microsoft.com...
> 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?
>
>
> --
> Michael Hockstein

Bookmark and Share