Subject Re: FireBird ODBC *Create* string
Author Dorin Vasilescu
Hi
Try this code, it will create a user DSN that will not be displayed
in Control Panel->ODBC

PROCEDURE SetDSN
LPARAMETERS tcDSN, tcAttrib
*tcDSN = name
*tcAttrib = string with DSN attributes, ';' as separator
#DEFINE SECURITY_ACCESS_MASK 983103 && SAM value KEY_ALL_ACCESS
#DEFINE HKEY_CLASSES_ROOT -2147483648
#DEFINE HKEY_CURRENT_USER -2147483647
#DEFINE HKEY_LOCAL_MACHINE -2147483646
#DEFINE HKEY_USERS -2147483645
#DEFINE CR CHR(13)

LOCAL lnResult, lnDisplay, lnAttribCount, i, lcEntry, lcValue
LOCAL ARRAY laAttrib[1]

DECLARE RegCreateKeyEx IN ADVAPI32.DLL
INTEGER,STRING,INTEGER,STRING,INTEGER,INTEGER,INTEGER,INTEGER @,
INTEGER @
DECLARE RegSetValueEx IN ADVAPI32.DLL
INTEGER,STRING,INTEGER,INTEGER,STRING,INTEGER

lnResult=0
lnDisplay=0

*create DSN key
RegCreateKeyEx
(HKEY_CURRENT_USER,"SOFTWARE\ODBC\ODBC.INI\"+tcDSN,0,"REG_SZ",0,SECUR
ITY_ACCESS_MASK,0,@lnResult,@lnDisplay)

*copy string with attributes to array and parse entries/values
lnAttribCount = ALINES(laAttrib,CHRTRAN(tcAttrib,';',CR))
FOR i=1 TO lnAttribCount
lcEntry = LEFT(laAttrib[i],ATC('=',laAttrib[i])-1)
lcValue = SUBSTR(laAttrib[i],ATC('=',laAttrib[i])+1)
RegSetValueEx(lnResult,lcEntry, 0 , 1 , lcValue, LEN(lcValue)
+1)
NEXT i
CLEAR DLLS "RegCreateKeyEx","RegSetValueEx"



> CreateUserDSN() which should work, and to an extent it does work:
>
> DECLARE INTEGER SQLConfigDataSource IN odbccp32 ;
> INTEGER, INTEGER, STRING, STRING
>
> lnSuccess = SQLConfigDataSource(0, 1, "Firebird/Interbase(r)
driver", ;
> "DSN=C07_VSO3Data_FB" + CHR(0) ;
> + "CharacterSet=NONE" + CHR(0) ;
> + "Client=" + CHR(0) ;
> + "Dbname=C:\vso3\projects\c07\data\vso3.fdb" + CHR(0) ;
> + "Dialect=3" + CHR(0) ;
> + "Driver=C:\WINNT\system32\OdbcJdbc.dll" + CHR(0) ;
> + "JdbcDriver=Iscdbc" + CHR(0) ;
> + "NoWait=N" + CHR(0) ;
> + "Password=masterkey" + CHR(0) ;
> + "QuotedIdentifier=N" + CHR(0) ;
> + "ReadOnly=N" + CHR(0) ;
> + "Role=" + CHR(0) ;
> + "User=SYSDBA" + CHR(0) ;
> )
>
Just the above 2 statements execute and we can do it
programatically.