What happened to SQLConfigDataSource_ ?

Just starting out? Need help? Post your questions and find answers here.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

What happened to SQLConfigDataSource_ ?

Post by Karbon »

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!

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
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
Fig
Enthusiast
Enthusiast
Posts: 352
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: What happened to SQLConfigDataSource_ ?

Post by Fig »

#ODBC_ADD_DSN equals 4
#ODBC_REMOVE_DSN equals 3
FYI...
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: What happened to SQLConfigDataSource_ ?

Post by Karbon »

Fig wrote:#ODBC_ADD_DSN equals 4
#ODBC_REMOVE_DSN equals 3
FYI...
ODBC_ADD_DSN should be 1, ODBC_ADD_SYS_DSN should be 4, or at least that's how it's been working for about 14 years in this code.. Likewise REMOVE_DSN is 3, REMOVE_SYS_DSN is 6..
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
User avatar
Fig
Enthusiast
Enthusiast
Posts: 352
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: What happened to SQLConfigDataSource_ ?

Post by Fig »

On Pb 5.44 Rts, the solely error raised up was about the constants. You solve it by replacing them by their values (Word type).
About the rest of the code, I don't see anything suspicious: it should work if it does before...
The calls looks fine.
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: What happened to SQLConfigDataSource_ ?

Post by Karbon »

Interesting, I get no compilation errors at all but did substitute the values for the constants just to test. Unfortunately no change (SQLConfigDataSource_() just returns zero).
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: What happened to SQLConfigDataSource_ ?

Post by Karbon »

FWIW, this has *something* to do with Unicode, but I'm not seeing it.

Free beer to the first person to spot it!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: What happened to SQLConfigDataSource_ ?

Post by freak »

You can try to get some information about why the command fails with the following code. Maybe this points you in the right direction.

Code: Select all

  If result = #False
    ErrorMessage$ = Space(255)
    ErrorCode.l = 0
    SQLInstallerError_(1, @ErrorCode, @ErrorMessage$, 255, #Null)
    Debug ErrorMessage$
  EndIf
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Re: What happened to SQLConfigDataSource_ ?

Post by Karbon »

Thanks freak! I should have mentioned that I tried calling SQLInstallerError_() already.. It returns "C" -- yep, just the letter C.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply