andyah

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
Auf Facebook teilen
Auf X (Twitter) teilen
Auf Reddit teilen
Auf Linkedin teilen

Content-ID: 157940

Url: https://administrator.de/forum/mit-vba-pruefen-ob-server-dsn-existiert-157940.html

Ausgedruckt am: 10.06.2025 um 23:06 Uhr

Logan000
Logan000 04.01.2011 um 10:14:57 Uhr
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.