ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by ts-soft »

http://dl.dropbox.com/u/3086026/ADOmate.zip should work for a short time :wink:
I hope srod will fix his webside.
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.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by srod »

ts-soft wrote:I hope srod will fix his webside.
He is a lazy bugger at the best of times! :wink:

I'll get on to it tonight... if I can find it!
I may look like a mule, but I'm not a complete ass.
jassing
Addict
Addict
Posts: 1775
Joined: Wed Feb 17, 2010 12:00 am

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by jassing »

coelhorb wrote:Please could you put ADOmate link available again? http://dl.dropbox.com/u/3086026/ADOmate.zip doesn't work any more and I can't find it anywhere on internet. The nxsoftware's site is out. Thanks and sorry for my poor english.
I just clicked the dropbox url and it downloaded w/o issue.
I mirrored it here: http://jassing.com/temp/adomate.zip -- but this doesn't mean it'll be there forever...

adomate is 3 years old...
coelhorb
New User
New User
Posts: 2
Joined: Tue Apr 17, 2012 11:23 am

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by coelhorb »

Thanks, it will help me a lot.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by ts-soft »

And http://www.nxsoftware.com/ is working again :D
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.
Image
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by srod »

ts-soft wrote:And http://www.nxsoftware.com/ is working again :D
Yes, but most of the links aren't! :)
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by byo »

hi, srod.

I'd like to suggest some fixes for using ADOMate with the Windows x64 compiler.

First, as I read in another topic, the EXCEPINFO structure is different in the x64 library so I'd suggest
a code in COMate like this one:

Code: Select all

;The following structure is used in the iDispatch\Invoke() method call to receive detailed errors.
  CompilerIf Defined(EXCEPINFO, #PB_Structure) = 0
  	CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
	  	Structure EXCEPINFO
	      wCode.w
	      wReserved.w
	      pad.b[4] ; Only on x64
	      bstrSource.i                ;BSTR
	      bstrDescription.i
	      bstrHelpFile.i
	      dwHelpContext.l
	      pvReserved.i
	      pfnDeferredFillIn.COMate_ProtoDeferredFillIn
	      scode.l
	      pad2.b[4] ; Only on x64
	   EndStructure
	CompilerElse
		Structure EXCEPINFO
	      wCode.w
	      wReserved.w
	      bstrSource.i                ;BSTR
	      bstrDescription.i
	      bstrHelpFile.i
	      dwHelpContext.l
	      pvReserved.i
	      pfnDeferredFillIn.COMate_ProtoDeferredFillIn
	      scode.l
	   EndStructure		
	CompilerEndIf
CompilerEndIf
Next, there is something wrong when the IDispatch\Invoke is called in the x64 version. There must be an additional error code for this version because every connection that should have caused an error returns "Okay.". I haven't tested it thoroughly but here's what I saw:

Replacing the first code with the second one should do the trick for every version:

Code: Select all

; ADOmate_OpenDatabase method - Line 1099
If SUCCEEDED(*connection\connectionObject\Invoke("Open('" + connection$ + "', " + user$ + ", " + password$ +")"))

Code: Select all

; ADOmate_OpenDatabase method - Line 1099
If *connection\connectionObject\Invoke("Open('" + connection$ + "', " + user$ + ", " + password$ +")") = #S_OK
;)

I hope that helps. With the changes above my code is working great in x86 and x64 versions.
BTW, thank you for this wonderful library.

EDIT: After more time debugging I think the problem resides in a deeper level. The COMateClass_INTERNAL_InvokePlus method returns a negative error number in the x86 compiler while it returns a positive one in x64. That's why the SUCCEEDED macro above always returns TRUE.

Best regards,

Andre Guerreiro Neto
Proud registered Purebasic user.
Because programming should be fun.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by srod »

Thanks byo, good work there.

I wonder if the problem with the error codes is that HRESULT values are actually 32-bit regardless of architecture? If this is the case then PBx64 could be misinterpreting the return values? Will need to get ahold of some c header files to be sure.

EDIT : yes I do think that PB x64 regards HRESULT as 64-bit integers rather than 32-bit longs. This would mean that PB x64 has all in-built interface methods which return HRESULT values incorrect.

I can easily add a workaround to COMate.

**EDIT : COMatePLUS workaround.

Code: Select all

    Macro SUCCEEDED(HRESULT)
      HRESULT & $80000000 = 0
    EndMacro
    Macro FAILED(HRESULT)
      HRESULT & $80000000
    EndMacro
This is only valid whilst the conjectured bug with PB stands.
Last edited by srod on Sat Nov 03, 2012 9:16 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by byo »

EDIT : yes I do think that PB x64 regards HRESULT as 64-bit integers rather than 32-bit longs. This would mean that PB x64 has all in-built interface methods which return HRESULT values incorrect.
Ah, so that's what's going on. :)
Thank you for your additional tests.

Interesting macro solution.
I have tested your fix in both compilers and both produce the correct output.
Should we inform Fred/freak about the issue or is there a bug report already filled?

[EDIT]: I was using only your macro solution without my altered code and it would still fail to show an error. Only when I changed the ADOmate line to compare the Invoke method result with #S_OK it would work properly for me in x64. :)

Thanks again, Stephen.

Best regards,

Andre Guerreiro Neto
Proud registered Purebasic user.
Because programming should be fun.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by srod »

You need to replace the original macro in COMatePLUS with the new one given above. I will post a bug report later.

*EDIT : sorry, the macro above was wrong, please try again with the new version.
I may look like a mule, but I'm not a complete ass.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by byo »

Thank you, srod.

It's working correctly now. I see what you did there but I can't quite understand it. I'm not good in Bitwise operators. :D
Nice work there.

Thanks again for the easy fix.

Best regards,

Andre Guerreiro Neto
Proud registered Purebasic user.
Because programming should be fun.
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by byo »

Hi. mr. srod. How's it going? :-D

I have an improvement to suggest. How about adding a new parameter to ADOMate_DatabaseQuery to set the cursorLocation property for the RecordSet?
This can have a huge impact on queries depending on the case, of course. Sometimes, when the cursor is executed at the client side it's faster and takes the burden off the server.

The changes you'd have to make (if you accept it) is:

Code: Select all

; The declaration:
Procedure.i ADOmate_DatabaseQuery(*connection._ADOmateConnection, request$, cursorType = #adOpenForwardOnly, cursorLocation = #adUseServer)

Code: Select all

; The definition (line 423):
If rset\SetProperty("CursorType = " + Str(cursorType)) = #S_OK And rset\SetProperty("CursorLocation = " + Str(cursorLocation)) = #S_OK And rset\Invoke("Open('" + request$ + "', " + Str(*connection\connectionObject) + " As COMateObject)") = #S_OK
Even if you can change that property later, the reason I ask this is because one has to close the connection to be able to change that property and then reopen it so the change will take effect.

Best regards,

Andre Guerreiro Neto
Proud registered Purebasic user.
Because programming should be fun.
Liqu
User
User
Posts: 77
Joined: Sun Apr 21, 2013 10:31 am

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by Liqu »

Hello,

i tried to use ADOmate to connect to password protected .mdb and .accdb, but failed.
it works great for unprotected .mdb.

here's my code

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***ADOmate*** - access to OLEDB datasources.
;*============
;*
;*Database query demo.
;*This demo requires the "ado.mdb" database file.
;/////////////////////////////////////////////////////////////////////////////////

IncludePath "..\"
XIncludeFile "ADOmate.pbi"


databaseFile$ = "D:\test.mdb"
connectionString$ = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + databaseFile$ + ";"
User$ = ""
Password$ = "test"
;Attempt to open the database.
myConnection = ADOmate_OpenDatabase(connectionString$,User$,Password$)

If myConnection

  ;Attempt to execute a basic query.
    SQL$ = "Select * from Test"
  If ADOmate_DatabaseQuery(myConnection, SQL$, #adOpenStatic)
    ;Let us display a list of columns.
      numColumns = ADOmate_DatabaseColumns(myConnection)
      If numColumns
        Debug "Columns : "
        Debug "--------------"
        For i = 0 To numColumns-1
          Debug "   " + ADOmate_DatabaseColumnName(myConnection, i) + " --> column type = " + Str(ADOmate_DatabaseColumnType(myConnection, i))
        Next
        Debug ""
      EndIf
    ;Now examine all records retrieved in the recordset.
      Debug "Rows : "
      Debug "--------------"
      While ADOmate_IsEOF(myConnection) = 0
        ID$ = ADOmate_GetDatabaseString(myConnection, 0)
        Integer$ = ADOmate_GetDatabaseString(myConnection, 1)
        Text$ = ADOmate_GetDatabaseString(myConnection, 2)
        Memo$ = ADOmate_GetDatabaseString(myConnection, 3)
        Debug "   (ID=" + ID$ + ", IntegerField=" + Integer$ + ", TextField=" + Text$ + ", MemoField=" + Memo$ + ")"
        ADOmate_NextDatabaseRow(myConnection)
      Wend
    ADOmate_FinishDatabaseQuery(myConnection)
  Else
    MessageRequester("ADOmate error!", ADOmate_GetLastErrorDescription())
  EndIf
  ADOmate_CloseDatabase(myConnection)
Else
  MessageRequester("ADOmate error!", ADOmate_GetLastErrorDescription())
EndIf
User avatar
Kiffi
Addict
Addict
Posts: 1361
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by Kiffi »

you must set your password in the Connectionstring:

Code: Select all

[...]
connectionString$ = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + databaseFile$ + ";Jet OLEDB:Database Password=test"
;Attempt to open the database.
myConnection = ADOmate_OpenDatabase(connectionString$, "", "")
[...]
Greetings ... Kiffi
Hygge
Liqu
User
User
Posts: 77
Joined: Sun Apr 21, 2013 10:31 am

Re: ADOmate - use OLE-DB datasources via ADO - (BLOBs added)

Post by Liqu »

Your code works great for .mdb
but it still can't connect to unprotected and protected .accdb, its said unrecognized database format.

Thank you very much for the lib srod and the correction Kiffi :D
Post Reply