Well, there is a simply way, if SQL Server is installed on the same machine you're interested in:
And then from ASP:
<% set conn = CreateObject("ADODB.Connection") conn.open "<connection string>" set rs = conn.execute("EXEC master..xp_enumDSN") if not rs.eof then do while not rs.eof response.write rs(0) & " (" & rs(1) & ")<br>" rs.movenext loop else response.write "No DSNs found." end if rs.close: set rs = nothing conn.close: set conn = nothing %> |
NOTE: You must have appropriate privileges to run extended stored procedures from the master database to pull this off.
Another way is to use WMI's StdRegProv:
<% Const HKLM = &H80000002 sPath = "Software\ODBC\ODBC.INI\ODBC Data Sources" Set oReg = GetObject("winmgmts:root/default:StdRegProv") o1 = oReg.EnumValues(HKLM, sPath, arNames, arTypes) for i = 0 to ubound(arNames) o2 = oReg.GetStringValue(HKLM, sPath, arNames(i), sValue) response.write arNames(i) & " (" & sValue & ")<br>" next Set oReg = Nothing %> |
Again, appropriate privileges are required either for the anonymous or the authenticated user, depending on how your security is configured.