by Brian Battles WS1O (15 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)
Finds SQL Servers on your LAN
Inputs
Needs you to enter your LAN's Domain name
Assumes
Modified from code originally uploaded by Mike G ([email protected]), which I found had a couple of problems. This version seems to fix them.
Code Returns
Returns a list of all SQL Servers found, in this example it places them into a combobox control
Side Effects
?
API Declarations' kernel32 declaration
Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (Destination As Any, _
Source As Any, _
ByVal Length As Long)
' netapi declarations
Private Declare Function NetServerEnum Lib "netapi32" ( _
strServername As Any, _
ByVal Level As Long, _
bufPtr As Long, _
ByVal PrefMaxLen As Long, _
EntriesRead As Long, _
TotalEntries As Long, _
ByVal ServerType As Long, _
strDomain As Any, _
ResumeHandle As Long) As Long
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" _
(ByVal lpBuffer As Long) As Long
Download GetSQLServers (4 KB)