Results 1 to 4 of 4

Thread: finding sql servers on the network.

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    finding sql servers on the network.

    Hello,

    I am creating a application that can connect any sql server on the network.

    The customer would like a dialog box to be able to find a instance of a server, and then enter the password and username to get a list of all the database they want to connect to.

    Does anyone have any examples projects in vb.net that does something like this.

    I will be most grateful for any code.

    Thanks in advance,

    Steve
    steve

  2. #2
    Banned
    Join Date
    Sep 2006
    Posts
    1

    Re: finding sql servers on the network.

    Actually finding general SQL servers on the network could prove troublesome. The idea you begin with when considering an SQL server is that you know exactly where it is at.

    You'd probably have to adopt a portscanner-type technique. However, this would be limited to the specific local IP range that you set (example: your app sees that an adapter has a local IP of 192.168.0.5, so it checks IPs 192.168.0.1-254). The main problem you are still faced with in this situation is that the SQL server must be running on a pre-defined port, or a small set of pre-defined ports.

    A full network scan may work, but it will be important that any internal security mechanisms do not stop it, and the servers must all be in one general IP range to be found, hopefully avoiding weird gateway hops into other ranges.

    I hope this helps out a bit. I primarily deal with SQL in Java, but I would be interested in taking this project up if you'd like. You can see http://www.vbforums.com/showthread.php?t=429437 in that case. (admins: I know I'm blatantly advertising here, so please let me know if this sort of thing is unacceptable )

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: finding sql servers on the network.

    You may want to have a look at http://pinvoke.net/default.aspx/netapi32.netserverenum

    You can call NetServerEnum and pass SV_TYPE_SQLSERVER as a flag.

    The code is in C# but shouldn't be too hard in VB.NET.
    If you're on the .net framework v 2.0 be sure and use a List<T> instead of the ArrayList used in the sample code for a performance boost.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: finding sql servers on the network.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width