ODBC mit VBS anlegen


Inhaltsverzeichnis


ODBC

Hier ein Beispiel wie man eine ODBC DSN mittels VBS erstellen kann

ODBC DSN mit VBS Anlegen
Const SystemFolder= 1
Dim FSO
Dim SysFolder
Dim SysFolderPath

Set FSO = wscript.CreateObject("Scripting.FileSystemObject")
Set SysFolder =fso.GetSpecialFolder(SystemFolder)
SysFolderPath= SysFolder.Path

'# Specify the DSN parameters.
DataSourceName = "myDSN"
DatabaseName = "DB"
Description = "ODBC Connection mit: " & DatabaseName
DriverPath = SysFolderPath & "\sqlsrv32.dll"
Server = "MYSERVER"
LastUser = "USERNAME"
DriverName = "SQL Server"

'# Create Shell Objekt
Set WshShell = WScript.CreateObject("WScript.Shell")

Dim RegEdPath
RegEdPath= "HKLM\SOFTWARE\ODBC\ODBC.INI\" & DataSourceName & "\"
WshShell.RegWrite RegEdPath , ""

WshShell.RegWrite RegEdPath & "Database" , DatabaseName
WshShell.RegWrite RegEdPath & "Description" , Description
WshShell.RegWrite RegEdPath & "Driver" , DriverPath
WshShell.RegWrite RegEdPath & "LastUser" , LastUser
WshShell.RegWrite RegEdPath & "Server" , Server

WshShell.RegWrite "HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\" & DataSourceName , DriverName

WSHShell.Popup "ODBC DSN successfully created.", 2, "ODBC", 64

top.gifZurück zum Inhalt


Copyright © November 2004 - Andres Bohren, Icewolf Software