Can someone help me get these functions working in 5.44? I'm not the original author of the code below but it served me very well for many years!
Code: Select all
Procedure AddODBCConnection(Driver$,Attributes$)
While Right(Attributes$,2)<>";;"
Attributes$+";"
Wend
;*LPAttribMem=AllocateMemory((Len(Attributes$)+1)*SizeOf(CHARACTER))
*LPAttribMem=AllocateMemory(Len(Attributes$)*SizeOf(CHARACTER)+SizeOf(CHARACTER))
PokeS(*LPAttribMem,Attributes$,Len(Attributes$))
For l=1 To Len(Attributes$)
CompilerIf #PB_Compiler_Unicode
If PeekW(*LPAttribMem + (l-1) * SizeOf(CHARACTER))=Asc(";")
PokeW(*LPAttribMem + (l-1) * SizeOf(CHARACTER),0)
EndIf
CompilerElse
If PeekB(*LPAttribMem + l -1)=Asc(";")
PokeB(*LPAttribMem + l -1,0)
EndIf
CompilerEndIf
Next
result=SQLConfigDataSource_(0,#ODBC_ADD_DSN,Driver$,*LPAttribMem)
FreeMemory(*LPAttribMem)
ProcedureReturn result
EndProcedure
Procedure RemoveODBCConnection(Driver$,DSN$)
DSN$="DSN="+DSN$
While Right(DSN$,2)<>";;"
DSN$+";"
Wend
*LPAttribMem=AllocateMemory((Len(DSN$)+1)*SizeOf(CHARACTER))
PokeS(*LPAttribMem,DSN$,Len(DSN$))
For l=1 To Len(DSN$)
CompilerIf #PB_Compiler_Unicode
If PeekW(*LPAttribMem + (l-1) * SizeOf(CHARACTER))=Asc(";")
PokeW(*LPAttribMem + (l-1) * SizeOf(CHARACTER),0)
EndIf
CompilerElse
If PeekB(*LPAttribMem + l -1)=Asc(";")
PokeB(*LPAttribMem + l -1,0)
EndIf
CompilerEndIf
Next
result=SQLConfigDataSource_(0,#ODBC_REMOVE_DSN,@Driver$,*LPAttribMem)
FreeMemory(*LPAttribMem)
ProcedureReturn result
EndProcedure