Need VB .NET code to enumerate all available SQL servers on a network
Category: Computers > Programming
Asked by: indmillert-ga
List Price: $30.00
02 Feb 2003 09:29 PST
Expires: 04 Mar 2003 09:29 PST
Question ID: 156352
I need to find an example program or code (VB .NET only) that will show how to enumerate a list of SQL servers that are available on a network. Previously under VB6 it was really only possible (that I know of) by using DMO. I have seen examples in C# that show using the netapi32.dll API (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=734&lngWId=10), but I would like to find either an example of this in VB .NET or find an easier way to do it....perhaps built into the ADO provider or .NET framework base classes.
Re: Need VB .NET code to enumerate all available SQL servers on a network
Answered By: hammer-ga on 02 Feb 2003 12:29 PST
There is a MSKB article with sample code for how to do this with VB. How to Enumerate Available SQL Servers Using SQLDMO http://support.microsoft.com/default.aspx?scid=KB;EN-US;287737 According to the VB.Net newsgroups, this will also work with VB.Net. Here is a link to one thread which discusses this: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf8&threadm=uquwpRyWCHA.1164%40tkmsftngp10&rnum=1&prev=/groups%3Fq%3D%2522VB.Net%2522%2Benumerate%2BSQL%2BServer%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf8%26selm%3DuquwpRyWCHA.1164%2540tkmsftngp10%26rnum%3D1 The newsgroup thread mentions that you will likely need a patch for SQLDMO. The necessary Service Packs can be downloaded from Microsoft. How to Obtain the Latest SQL Server 2000 Service Pack http://support.microsoft.com/default.aspx?scid=kb;en-us;Q290211 There is another newsgroup posting with a tip for another issue you may encounter. "I've used SQLDMO in a VB.NET Beta-1 solution. I had to put "Option Strict Off" in the first line of the module where I'm using it. Then I used late binding (CreateObject("SQLDMO.Application") and so on). This worked fine for me." Once you have a server, you can use DMO to enumerate the databases by traversing the Databases collection. If you don't want to use DMO, you can create and ADO connection to the server and run a query something like: SELECT NAME FROM SYSDATABASES ----------------------------------------- Additional Resources: Microsoft SQL-DMO Reference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_ob_3tlx.asp Google Search/Google Groups Search terms SQLDMO enumerate SQL Server VB Newsgroups: microsoft.public.dotnet.languages.vb microsoft.public.sqlserver.programming ---------------------------------- Good luck with your VB.Net project! - Hammer
|indmillert-ga rated this answer:|
|There are no comments at this time.|
If you feel that you have found inappropriate content, please let us know by emailing us at firstname.lastname@example.org with the question ID listed above. Thank you.
|Search Google Answers for|