Tony72
(Getting the hang of it)
2002-06-19 10:43 PM
WinNT ODBC

Actaully, this relates to my little NT Term Server problem today. Is anyome familar with ways of adding entries to ODBC under NT? Offhand I would assume it is just something that eventally gets thrown into the registry, but dont have access to the programs to check it at the moment.

Les
(KiX Master)
2002-06-20 02:39 AM
Re: WinNT ODBC

Well... assuming the driver is present, you are correct in that it's just a few reg entries. Just export the reg before and after and then do a file compare on the two exports. Alternately, you could use a program like RegMon to eavesdrop on all reg i/o but then there's too much to have to wade through.

Here's a sample. In my case the script does two things, 1; install if not present and 2; modify to reflect a change implemented.
code:
$HKLMSOOA = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\API400Q"
$HKLMSOOIS = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ShowCase ODBC"

? "Check to see if the Showcase DLL is installed"
$SCODBC32DLL = ReadValue($HKLMSOOIS,"Driver")
If Exist($SCODBC32DLL)
? "Found " + $SCODBC32DLL
; ********************************************************************
? "Check to see if the Showcase ODBC Data Source is defined"
; ********************************************************************
If Not KeyExist($HKLMSOOA)
? " Not there so create it..."
$RC = AddKey($HKLMSOOA)
$RC = WriteValue($HKLMSOOA,"AccessMode","Read/Write", REG_SZ)
$RC = WriteValue($HKLMSOOA,"AsyncConnections","No", REG_SZ)
$RC = WriteValue($HKLMSOOA,"CollectionRequired","No", REG_SZ)
$RC = WriteValue($HKLMSOOA,"CommType","Windows TCP/IP Sockets", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Compression","Off", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Description","Query Link to AS/400", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Driver",$SCODBC32DLL, REG_SZ)
$RC = WriteValue($HKLMSOOA,"HostCodePage","0 - Default", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Library","SCSERVER", REG_SZ)
$RC = WriteValue($HKLMSOOA,"LogFile","c:\winnt\system32\api400q.log", REG_SZ)
$RC = WriteValue($HKLMSOOA,"LogLevel","No Log", REG_SZ)
$RC = WriteValue($HKLMSOOA,"LUAlias","APIQ", REG_SZ)
$RC = WriteValue($HKLMSOOA,"OemToAnsi","Yes", REG_SZ)
$RC = WriteValue($HKLMSOOA,"ReadUncommitted","Auto", REG_SZ)
$RC = WriteValue($HKLMSOOA,"ServerType","FULL", REG_SZ)
$RC = WriteValue($HKLMSOOA,"StmtCurlibPrompt","No", REG_SZ)
$RC = WriteValue($HKLMSOOA,"System","APIPRODA", REG_SZ)
$RC = WriteValue($HKLMSOOA,"TcpPort","43419", REG_SZ)
$RC = WriteValue($HKLMSOOA,"USEJOURNALS","No", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Year2000WatershedDate","40", REG_SZ)
$RC = WriteValue($HKLMSOOA,"Year2000WatershedDateEnabled","Yes", REG_SZ)
Else
? 'Check to see if the "CommType" is "Windows TCP/IP Sockets"'
$CommType = ReadValue($HKLMSOOA,"CommType")
If $CommType <> "Windows TCP/IP Sockets"
? "Not, so updating..."
$RC = WriteValue($HKLMSOOA,"CommType","Windows TCP/IP Sockets", REG_SZ)
EndIf
? 'Check to see if the "System" is "APIPRODA"'
$System = ReadValue($HKLMSOOA,"System")
If $System <> "APIPRODA"
? "Not, so updating..."
$RC = WriteValue($HKLMSOOA,"System","APIPRODA", REG_SZ)
EndIf
EndIf
EndIf

? "Done!"
EXIT 1



Kdyer
(KiX Supporter)
2002-06-20 04:24 AM
Re: WinNT ODBC

Tony,

I know this may not be as elegant as Les', but it may also help. [Wink] What is your Application? MS-Access, SQL Server, Oracle, VFP?

Here is one that we use for a Software Application in Production.

code:
 $hklms = 'HKEY_LOCAL_MACHINE\SOFTWARE'

; This adds in the Application ODBC Connection for the Control Panel
:Application
;Check for the existence of the ODBC Data Sources For the Control Panel
IF 0 <> EXISTKEY($hklms+"\ODBC\ODBC.INI\ODBC Data Sources")
$RC = ADDKEY($hklms+"\ODBC\ODBC.INI\ODBC Data Sources")
ENDIF
IF 0 = ExistKey($hklms+"\ODBC\ODBC.INI\Application")
;IF THEY HAVE THE ODBC CONNECTION
RETURN
ELSE
;ADD A DATASOURCE FOR THE CONTROL PANEL
$rc=WRITEVALUE($hklms+"\ODBC\ODBC.INI\ODBC Data Sources","Application","Microsoft Visual FoxPro Driver","REG_SZ")
;SET THE REGISTRY PATH STRING
$odbcpath = $hklms+"\ODBC\ODBC.INI\Application"
;ASSUME THE STRING DOESN'T EXIST
$RC = ADDKEY($odbcpath)
;NOW, WRITE SOME VALUES FOR THIS ODBC CONNECTION
$RC = WRITEVALUE($odbcpath,"Driver","%windir%\SYSTEM32\VFPODBC.dll","REG_SZ")
$RC = WRITEVALUE($odbcpath,"SourceDB","R:\Appliction\Tables\application.DBC","REG_SZ")
$RC = WRITEVALUE($odbcpath,"Description","","REG_SZ")
$RC = WRITEVALUE($odbcpath,"SourceType","DBC","REG_SZ")
$RC = WRITEVALUE($odbcpath,"BackgroundFetch","No","REG_SZ")
$RC = WRITEVALUE($odbcpath,"Exclusive","No","REG_SZ")
$RC = WRITEVALUE($odbcpath,"Null","Yes","REG_SZ")
$RC = WRITEVALUE($odbcpath,"Deleted","Yes","REG_SZ")
$RC = WRITEVALUE($odbcpath,"Collate","Machine","REG_SZ")
$RC = WRITEVALUE($odbcpath,"SetNoCountOn","No","REG_SZ")
RETURN
ELSE
RETURN
ENDIF