Hi folks,
I use ODBC to read Excel Files. For every new file, it's necessary to create a DSN first, to define the datasource.
But (may be) since PB5.40, the command: SQLConfigDataSource_() allways failed.
What was changed and what can I do now?
Ciao dige
Excel, ODBC and SQLConfigDataSource
Excel, ODBC and SQLConfigDataSource
"Daddy, I'll run faster, then it is not so far..."
Re: Excel, ODBC and SQLConfigDataSource
Hi, I don't know answer to your question, but perhaps you could consider accessing Excel via COM?
http://www.forums.purebasic.com/english ... 33#p462333
http://www.forums.purebasic.com/english ... 33#p462333
Re: Excel, ODBC and SQLConfigDataSource
Thx bbanelli, for that hint. But since PB supports ODBC databases, I prefer to use the PB command set..
"Daddy, I'll run faster, then it is not so far..."
Re: Excel, ODBC and SQLConfigDataSource
Bad news!dige wrote:But (may be) since PB5.40, the command: SQLConfigDataSource_() allways failed.

I'm also interested in a solution.dige wrote:What was changed and what can I do now?
Here is the (faulty) code:
Code: Select all
Procedure.i AddConnection(driver$, connectString$)
Protected result, base, *mem.CHARACTER, *ptr.CHARACTER, len, i
If driver$ And connectString$
len = Len(connectString$)
base = AllocateMemory((len + 2)<<(SizeOf(CHARACTER)-1))
If base
*mem = base
*ptr = @connectString$
;Switch all ; for nulls.
For i = 1 To len
If *ptr\c <> ';'
*mem\c = *ptr\c
EndIf
*mem + SizeOf(CHARACTER)
*ptr + SizeOf(CHARACTER)
Next
result = SQLConfigDataSource_(0, #ODBC_ADD_DSN, driver$, base)
FreeMemory(base)
If result
ProcedureReturn 1
EndIf
EndIf
EndIf
EndProcedure
Procedure.i RemoveConnection(Driver.s,DSN.s)
Protected Result
Result=SQLConfigDataSource_(0,#ODBC_REMOVE_DSN,Driver,"DSN="+DSN)
If Result
ProcedureReturn 1
EndIf
EndProcedure
Hygge
-
- User
- Posts: 47
- Joined: Sun Feb 18, 2007 11:57 am
Re: Excel, ODBC and SQLConfigDataSource
Hi.
Have you tried to launch your app with admin rights in PB IDE (Compiler Options) ?
Regards.
Have you tried to launch your app with admin rights in PB IDE (Compiler Options) ?
Regards.
Re: Excel, ODBC and SQLConfigDataSource
the code above works fine with PB V5.31. Since V5.4 it fails. So i think it's not a rights problem.linkerstorm wrote:Have you tried to launch your app with admin rights in PB IDE (Compiler Options) ?
i guess the code fails her:
Code: Select all
result = SQLConfigDataSource_(0, #ODBC_ADD_DSN, driver$, base)
Thanks in advance & Greetings ... Peter
Hygge
Re: Excel, ODBC and SQLConfigDataSource
Have you used: Unicode and X86 ?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Re: Excel, ODBC and SQLConfigDataSource
Hello Thomas,
thanks for your quick reply! Unicode was the magic word. Now it works as expected.
Thanks & Greetings ... Peter
thanks for your quick reply! Unicode was the magic word. Now it works as expected.

Thanks & Greetings ... Peter
Hygge