Page 1 of 1 1
Topic Options
#23561 - 2002-06-19 10:43 PM WinNT ODBC
Tony72 Offline
Getting the hang of it

Registered: 2002-06-18
Posts: 53
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.
_________________________
Be kind; each person is fighting his own private war.

Top
#23562 - 2002-06-20 02:39 AM Re: WinNT ODBC
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#23563 - 2002-06-20 04:24 AM Re: WinNT ODBC
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
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

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 150 anonymous users online.
Newest Members
Hdrthtsr19956, Kylie99, msmile042, rayd8, HardKn0X
17597 Registered Users

Generated in 0.032 seconds in which 0.013 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org