It is currently Mon Nov 20, 2017 12:59 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: [Done] PB v5.4x Invalid call of SQLConfigDataSource
PostPosted: Mon Dec 12, 2016 1:54 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
PB version greater as v5.31 calling always sql function as widechar...

ASCII Code
Code:
result = SQLConfigDataSource_(0, 1, "Microsoft Excel Driver (*.xls)", "strAttributes")
CallDebugger

ASM-Output
Code:
...
; result = SQLConfigDataSource_(0, 1, "Microsoft Excel Driver (*.xls)", "strAttributes")
  MOV    eax,_S2
  PUSH   eax
  MOV    eax,_S1
  PUSH   eax
  PUSH   dword 1
  PUSH   dword 0
  CALL  _SQLConfigDataSourceW@16
  MOV    dword [v_result],eax
...

:(

Bugfix for X86 (Update)
Code:
; Bugfix ASCII, Unicode PB v5.4x
Import "odbccp32.lib"
  CompilerIf #PB_Compiler_Unicode
    SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen) As "_SQLInstallerErrorW@20"
    SQLConfigDataSource(Handle, Type, strDriver.s, strAttribtues.s) As "_SQLConfigDataSourceW@16"
  CompilerElse
    SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen)
    SQLConfigDataSource(Handle, Type, strDriver.s, strAttribtues.s)
  CompilerEndIf 
EndImport

Import "odbc32.lib"
  CompilerIf #PB_Compiler_Unicode
    SQLConnect(ConnectionHandle, ServerName.s, NameLength1, UserName.s, NameLength2, Authentication.s, NameLength3) As "_SQLConnectW@28"
    SQLTables(StatementHandle, *CatalogName, NameLength1, *SchemaName, NameLength2, *TableName, NameLength3, *TableType, NameLength4) As "_SQLTablesW@36"
  CompilerElse
    SQLConnect(ConnectionHandle, ServerName.s, NameLength1, UserName.s, NameLength2, Authentication.s, NameLength3)
    SQLTables(StatementHandle, *CatalogName, NameLength1, *SchemaName, NameLength2, *TableName, NameLength3, *TableType, NameLength4)
  CompilerEndIf 
EndImport
; -----------------------------------------------------------------------------

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Sat Jan 28, 2017 7:23 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
Is it possible to fix this bug in the 5.60 Version FRED please ???
I use this function in one of my code and be forcing to use two version of PB for the same code :|
Thanks in advance 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Mon Feb 06, 2017 4:12 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
FRED can you say, if you can do something for that please ? :|

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Mon Feb 06, 2017 4:18 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13141
Location: France
It should be no problem on 5.60, as it's already widechar


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Tue Feb 07, 2017 11:33 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
Fixed into the next of PB v5.44 LTS ? (ASCII)

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Wed Feb 15, 2017 12:46 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
Fred wrote:
It should be no problem on 5.60
Hello FRED
This code works very well in v5.31 (Ascii or UNICODE) and not in v5.60
Code:
Res.w = SQLTables_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4), 0, "%", 0, 0, 0, 0, 0, 0)
Return -2 :shock:
Code:
#ODBC_ADD_DSN = 1            ; Add Data source
#ODBC_CONFIG_DSN = 2         ; Configure (edit) Data source
#ODBC_REMOVE_DSN = 3         ; Remove Data source
#ODBC_ADD_SYS_DSN = 4        ; add a system DSN
#ODBC_CONFIG_SYS_DSN = 5     ; Configure a system DSN
#ODBC_REMOVE_SYS_DSN = 6     ; remove a system DSN
#ODBC_REMOVE_DEFAULT_DSN = 7 ; remove the default DSN

#SQL_SUCCESS                        =   0
#SQL_SUCCESS_WITH_INFO              =   1
#SQL_ERROR                          =  -1
#SQL_INVALID_HANDLE                 =  -2
#SQL_NO_DATA                        = 100
#SQL_MAX_MESSAGE_LENGTH             = 512

#BaseDonnee = 0

CheminFichierExcel.s + "ExcelVide.xls"
Define *Buffer.Character

; Connection a la base de donnée Excell
Base.s = "Pure_Viewer"
StrDriver.s = "Microsoft Excel Driver (*.xls)"
StrAttributes.s = "Server=APServer;Description=" + Base
StrAttributes.s + ";DSN=" + Base
StrAttributes.s + ";DBQ=" + CheminFichierExcel
StrAttributes.s + ";UID=" + ""
StrAttributes.s + ";PWD=" + ""+ ";"
*Buffer = @StrAttributes

For L = 0 To Len(StrAttributes) - 1
 
 If *Buffer\c = ';'
  *Buffer\c = 0
 EndIf
 
 *Buffer + 1
 
Next L

UseODBCDatabase()
SQLConfigDataSource_(0, #ODBC_ADD_DSN, StrDriver, @StrAttributes)   ; Call the function you need from the ODBC library with the right details

; Ouverture de la base
If Base

 If OpenDatabase(#BaseDonnee, Base, "", Password$)
 
  SQLCancel_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4))
  Res.w = SQLTables_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4), 0, "%", 0, 0, 0, 0, 0, 0)
 
  If Res = #SQL_SUCCESS Or Res = #SQL_SUCCESS_WITH_INFO
   
   While NextDatabaseRow(#BaseDonnee)
    Debug GetDatabaseString(#BaseDonnee, 2)
   Wend
   
  EndIf
 
 EndIf
 
EndIf

If IsDatabase(#BaseDonnee)
 CloseDatabase(#BaseDonnee)
EndIf

Like usually i don't understand why :oops: , so i have asked, viewtopic.php?p=498374#p498374
and MkSoft found the problem and create this discussion in bug windows 8)

This is the EXCEL file empty i use
http://erdsjb.free.fr/purestorage/provi ... elVide.xls
Can you say to me, for i know, if it's my fault, or a bug you can fix a day, please
I wait your answer since a long time :wink: because i'm forced to use two version of PB in the same code, for use all the functions of my soft :|

Thanks in advance 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Wed Feb 15, 2017 9:03 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
The char ';' is thus not completely replaced, because the function Len (...) is called up each time and only returns the length to end (NULL).
Code:
Define *Buffer.Character

; Connection a la base de donnée Excell
Base.s = "Pure_Viewer"
StrDriver.s = "Microsoft Excel Driver (*.xls)"
StrAttributes.s = "Server=APServer;Description=" + Base
StrAttributes.s + ";DSN=" + Base
StrAttributes.s + ";DBQ=" + CheminFichierExcel
StrAttributes.s + ";UID=" + ""
StrAttributes.s + ";PWD=" + ""+ ";"
*Buffer = @StrAttributes

len = Len(StrAttributes) - 1
; For L = 0 To Len(StrAttributes) - 1 ; <-- Bug or feature?
For L = 0 To len
 
 If *Buffer\c = ';'
  *Buffer\c = 0
 EndIf
 
 *Buffer + SizeOf(Character)
 
Next L

ShowMemoryViewer(@StrAttributes, 160)


P.S. I show into my ExDatabase.pbi (Link viewtopic.php?f=12&t=67180)
Thats right...

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Thu Feb 16, 2017 2:46 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
Hello MkSoft

Excuse me , but i not really understand what you mean :oops:

You say i have a bug in my code ?

I must replace

Code:
Define *Buffer.Character

; Connection a la base de donnée Excell
Base.s = "Pure_Viewer"
StrDriver.s = "Microsoft Excel Driver (*.xls)"
StrAttributes.s = "Server=APServer;Description=" + Base
StrAttributes.s + ";DSN=" + Base
StrAttributes.s + ";DBQ=" + CheminFichierExcel
StrAttributes.s + ";UID=" + ""
StrAttributes.s + ";PWD=" + ""+ ";"
*Buffer = @StrAttributes

For L = 0 To Len(StrAttributes) - 1
 
 If *Buffer\c = ';'
  *Buffer\c = 0
 EndIf
 
 *Buffer + 1
 
Next L
by
Code:
Define *Buffer.Character

; Connection a la base de donnée Excell
Base.s = "Pure_Viewer"
StrDriver.s = "Microsoft Excel Driver (*.xls)"
StrAttributes.s = "Server=APServer;Description=" + Base
StrAttributes.s + ";DSN=" + Base
StrAttributes.s + ";DBQ=" + CheminFichierExcel
StrAttributes.s + ";UID=" + ""
StrAttributes.s + ";PWD=" + ""+ ";"
*Buffer = @StrAttributes

len = Len(StrAttributes) - 1
; For L = 0 To Len(StrAttributes) - 1 ; <-- Bug or feature?
For L = 0 To len
 
 If *Buffer\c = ';'
  *Buffer\c = 0
 EndIf
 
 *Buffer + SizeOf(Character)
 
Next L

ShowMemoryViewer(@StrAttributes, 160)


Ok 8)
But that's not change the problem between V5.31 and v5.60 ??? it's that ? :D

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Thu Feb 16, 2017 5:02 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 299
Location: France
I do not know if this is useful:
https://support.microsoft.com/en-us/help/2721825/unable-to-create-dsn-for-microsoft-office-system-driver-on-64-bit-versions-of-windows

I can read an xls file (95-2003 format) with PB 5.60 B4 x64 and ODBC 32 (Windows 10 x64)
(But I let the ODBC drivers take care of everything and I just use the named area in excel to set the database zone. So no API use in PB code)

:wink:

_________________
(English is not my native language, I used an online translator)
Windows 10 x64 - CPU intel i3 - RAM 16Go - Video NVidia GT 620 - 1920x1080
Linux Debian 8 / xfce (VM & Raspberry)
http://mdacme.com


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Thu Feb 16, 2017 5:08 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
Hello MARC :D
Perhaps... i have W10 X64 in another machine, but on this, i have W7 X86 v5.60B3 and that not works :|
Thanks 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Fri Jun 16, 2017 6:18 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Mon Jun 02, 2003 1:42 am
Posts: 2004
Location: Ashland, KY
I've been using the code below for years, and suddenly it doesn't work in PB 5.4X anymore.. MkSoft - I've tried using your updated code but I'm not seeing how it is doing anything I'm not. It doesn't work for me at all, even in a standalone test project. My one restriction is that I cannot use Unicode in this project.


Code:
Procedure AddODBCConnection(Driver$,Attributes$)
  While Right(Attributes$,2)<>";;"
    Attributes$+";"
  Wend
 
   
  *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


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Fri Jun 16, 2017 8:11 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
Not Tested...

Update
Code:
#ODBC_ADD_DSN                       = 1; // Add data source
#ODBC_CONFIG_DSN                    = 2; // Configure (edit) Data source
#ODBC_REMOVE_DSN                    = 3; // Remove data source
#ODBC_ADD_SYS_DSN                   = 4; // add a system DSN
#ODBC_CONFIG_SYS_DSN                = 5; // Configure a system DSN
#ODBC_REMOVE_SYS_DSN                = 6; // remove a system DSN
#ODBC_REMOVE_DEFAULT_DSN            = 7; // remove the default DSN

; Bugfix ASCII, Unicode PB v5.4x
Import "odbccp32.lib"
  CompilerIf #PB_Compiler_Unicode
    CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
      SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen) As "_SQLInstallerErrorW@20"
      SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues) As "_SQLConfigDataSourceW@16"
    CompilerElse
      SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen) As "SQLInstallerErrorW"
      SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues) As "SQLConfigDataSourceW"
    CompilerEndIf 
  CompilerElse
    SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen)
    SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues)
  CompilerEndIf 
EndImport

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

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Fri Jun 16, 2017 8:29 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Mon Jun 02, 2003 1:42 am
Posts: 2004
Location: Ashland, KY
PERFECT!

_________________
-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


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Sat Jun 17, 2017 5:10 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 3949
Location: Lyon - France
Hello MkSoft

I use a empty excel file, why your code not works for me in v5.60 ? :cry:

Code:
#ODBC_ADD_DSN                       = 1; // Add data source
#ODBC_CONFIG_DSN                    = 2; // Configure (edit) Data source
#ODBC_REMOVE_DSN                    = 3; // Remove data source
#ODBC_ADD_SYS_DSN                   = 4; // add a system DSN
#ODBC_CONFIG_SYS_DSN                = 5; // Configure a system DSN
#ODBC_REMOVE_SYS_DSN                = 6; // remove a system DSN
#ODBC_REMOVE_DEFAULT_DSN            = 7; // remove the default DSN

#BaseDonnee = 0

UseODBCDatabase()

; Bugfix ASCII, Unicode PB v5.4x
Import "odbccp32.lib"
 CompilerIf #PB_Compiler_Unicode
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
   SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen) As "_SQLInstallerErrorW@20"
   SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues) As "_SQLConfigDataSourceW@16"
  CompilerElse
   SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen) As "SQLInstallerErrorW"
   SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues) As "SQLConfigDataSourceW"
  CompilerEndIf
 CompilerElse
  SQLInstallerError(iError, *pfErrorCode, *ErrorMSGBuf, cbErrorMsgMax, *ErrorMSGLen)
  SQLConfigDataSource(Handle, Type, strDriver.s, *strAttribtues)
 CompilerEndIf
EndImport

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

CheminFichierExcel$ = "ExcelVide.xls"

; Connection a la base de donnée Excell
Base.s = "Pure_Viewer"
StrDriver.s = "Microsoft Excel Driver (*.xls)"
StrAttributes.s = "Server=APServer;Description=" + Base
StrAttributes.s + ";DSN=" + Base
StrAttributes.s + ";DBQ=" + CheminFichierExcel$
StrAttributes.s + ";UID=" + ""
StrAttributes.s + ";PWD=" + ""+ ";"

If AddODBCConnection(StrDriver, StrAttributes)

 If OpenDatabase(#BaseDonnee, Base, "", Password$)
 
  SQLCancel_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4))
  Res.w = SQLTables_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4), 0, "%", 0, 0, 0, 0, 0, 0)
 
  If Res = #SQL_SUCCESS Or Res = #SQL_SUCCESS_WITH_INFO
   
   While NextDatabaseRow(#BaseDonnee)
    Debug GetDatabaseString(#BaseDonnee, 2)
   Wend
   
  EndIf
 
 EndIf
 
 RemoveODBCConnection(StrDriver, Base)
 
EndIf



_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Sat Jun 17, 2017 10:33 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 1035
Location: Germany
The code is not from me, but 'AddODBCConnection(...)' work.

This code is not longer work, because PB v5.60 was change internal
Code:
    SQLCancel_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4))
    Res.w = SQLTables_(PeekL(PeekL(IsDatabase(#BaseDonnee) + 4) + 4), 0, "%", 0, 0, 0, 0, 0, 0)

Use the code 'ExDatabase.pbi' Link viewtopic.php?f=12&t=67180
Code:
; Tabellen lesen
If ExamineTables(dsn1)
  Debug "Tabellen in Database:"
  Debug ""
  While NextTable()
    Debug GetTableName() + "  <--  " + GetTableType()
  Wend
  Debug "" : Debug ""
Else
  Debug "Fehler."
EndIf

_________________
My Projects OOP-BaseClass / OOP-BaseClassDispatch / Event-Designer /
PB v3.30 / v5.60 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye