It is currently Mon Feb 27, 2017 12:50 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: [PB v5.4x] Invalid call of SQLConfigDataSource
PostPosted: Mon Dec 12, 2016 1:54 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 692
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
; -----------------------------------------------------------------------------

_________________
Sorry, My english is not so good
OOP-BaseClass / OPC-Helper DLL / Event-Designer /
PB v3.30 / v5.50 - OS Mac Mini OSX 10.xx / Window 7 Pro. (X64) / Window XP Pro. (X86) / Ubuntu 14.04
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: 3696
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: 3696
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: 12919
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
Enthusiast
Enthusiast
User avatar

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

_________________
Sorry, My english is not so good
OOP-BaseClass / OPC-Helper DLL / Event-Designer /
PB v3.30 / v5.50 - OS Mac Mini OSX 10.xx / Window 7 Pro. (X64) / Window XP Pro. (X86) / Ubuntu 14.04
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: 3696
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
Enthusiast
Enthusiast
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 692
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...

_________________
Sorry, My english is not so good
OOP-BaseClass / OPC-Helper DLL / Event-Designer /
PB v3.30 / v5.50 - OS Mac Mini OSX 10.xx / Window 7 Pro. (X64) / Window XP Pro. (X86) / Ubuntu 14.04
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: 3696
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: 192
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 - PureBasic 5.51 & 5.6 beta - Video NVidia GT 620 - 1920x1080 & Linux Debian / xfce (on Virtualbox 5)


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: 3696
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  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 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