What happened to SQLConfigDataSource_ ?
Posted: Thu Jun 15, 2017 9:20 pm
I'm using 5.44LTS, and cannot use Unicode (for a variety of reasons). 5.1 and 5.2 compiled and used this code just fine but 5.44LTS does not. I've seen several other threads about this but the solution was "use Unicode" -- but I can't in this case.. I'm not entirely sure where the unicode tie-in is, either.. The few other examples I've seen claim to work but do not for me (the ExDatabase update for example)..
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!
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