andyah
Goto Top

Mit VBA prüfen, ob Server-DSN existiert

VBA - prüfen, ob Server-DSN existiert

Hi NG,

nochmals eine Frage zum Thema System-DSN.

Wie kann ich per VBA prüfen, ob eine System-DSN auf dem Rechner existiert?

Gruß
Andy

Content-Key: 157940

Url: https://administrator.de/contentid/157940

Printed on: April 19, 2024 at 23:04 o'clock

Member: Logan000
Logan000 Jan 04, 2011 at 09:14:57 (UTC)
Goto Top
Moin Moin

So in etwa solte das funktionieren:
On error resume next
Set oShell = WScript.CreateObject("WScript.Shell")   
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\"   
myDNS = "NameDerGesuchtenDSN"          ' <- Hier must du natürluch den Namen deiner DSN angeben  
DBName = oShell.RegRead("HKEY_LOCAL_MACHINE\" & strKeyPath & myDNS & "\Database")  
if DBName <>"" Then  
	wscript.echo "DSN: " & myDNS & " existiert."   
end if

Gruß L.