Searching for Available SQL databases?

NetDog

Member
Joined
Feb 28, 2008
Messages
9
Programming Experience
1-3
Hi,

I'm new to VB - first post!

Currently I'm using VS 2005 Pro and getting to grips with VB (Flex/Janus,ActionScript,PHP background). If I add a DataSource, VS gives me the option of selecting from the various SQL 2005 Servers which are on my network.

I wish to create an application which can live on my laptop and check for any SQL servers which it finds on the network which it is plugged into. I can then enter a username and password as given to me by the SQL Server owner(s) in order to manipulate the tables.

Can anyone please recommend a tutorial which will educate me as to how to achieve this please?

Sorry if it's a basic question.
 
OK, in order to help myself I managed to find an example of the MS site.

I now have:

VB.NET:
Public Class Form1

    Private Sub Button1_Click()
        Dim i As Integer
        Dim oNames As SQLDMO.NameList
        Dim oSQLApp As SQLDMO.Application
        oSQLApp = New SQLDMO.Application

        oNames = oSQLApp.ListAvailableSQLServers()
        ListBox1.ClearSelected()

        For i = 1 To oNames.Count
            ListBox1.AddItem(oNames.Item(i))
        Next i


    End Sub
End Class

but VS complains that it does not like AddItem for my ListBox1. I'm guessing that the MS VB example is using old syntax.

Any pointers much appreciated. I didn't find anything useful in the help (so far)
 
SQL-DMO is obsolete, don't use it. Instead reference Microsoft.SqlServer.Smo.
VB.NET:
'Imports Microsoft.SqlServer.Management.Smo
Dim dt As DataTable = SmoApplication.EnumAvailableSqlServers
Me.DataGridView2.DataSource = dt
 
Back
Top