Sign in to follow this  
Followers 0
paz

ADODB.Recordset

9 posts in this topic

I am playing with ADODB.Recordset objects theses days, and while testing my script under Win64, I noticed that one of my function that usually returns the number of records always return 0 when running with AutoITx64.

Here is a simple code sample, assuming you have a ADO recordset saved as a XML file named "data.xml" in the script folder:

$RST = ObjCreate("ADODB.Recordset")
    
;client-side cursor... but I'd be really surprized if it changed anything with XML recordsets.
    $RST.Cursorlocation = 3

;In my case, this recordset was previously saved - contains 10 records.
    $RST.Open(@scriptdir & "\data.xml")
    
;Here, I use the recordcount property. With AutoIT 32bit, returns 10. With AutoITx64, returns 0 (?!)
    MsgBox(0,"Using Recordcount property",$RST.Recordcount)
    
;Here, I seek the whole recordset, and increment a variable
    $recordcount =0
    While $RST.eof <> TRUE
        $recordcount +=1
        $RST.MoveNext
    WEnd
    
;Here, in both AutoITx64 and Autoit 32bit, returns 10
    MsgBox(0,"Manually counting records",$recordcount)
    
    $RST.Close
    $RST=0

I haven't found much on MSDN clearly saying that 64bit ADO doesn't support the recordcount property... And since I'm working with offline XML files, I assume it should be fairly trivial to populate that property anyway.

Anyone is aware if this is normal behavior?

Share this post


Link to post
Share on other sites



http://www.adopenstatic.com/Faq/recordcounterror.asp

Have you tried changing cursor location to adOpenStatic (3)?

Thanks for the link.

I beleive that since I'm opening a local XML file, it's implicit that the cursorlocation is client-side AND CursorType is static... I tried to specify anyway, but no luck: still get "0" RecordCount under Win64

No big deal - I'll use the loop method to count the records if @AutoItx64 is true, until I find what's "wrong" ;-)

Share this post


Link to post
Share on other sites

Just a thought... Could you try

$RST.MoveLast

Before Checking for $RST.Recordcount? You then need to $RST.MoveFirst before the While NOT $RST.EOF Loop

Thanks for the link.

I beleive that since I'm opening a local XML file, it's implicit that the cursorlocation is client-side AND CursorType is static... I tried to specify anyway, but no luck: still get "0" RecordCount under Win64

No big deal - I'll use the loop method to count the records if @AutoItx64 is true, until I find what's "wrong" ;-)

Share this post


Link to post
Share on other sites

You may have to use a query string in the $RST.Open before you can get a count.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

You may have to use a query string in the $RST.Open before you can get a count.

How so? OP is using a local (cached) XML disk file.

Share this post


Link to post
Share on other sites

How so? OP is using a local (cached) XML disk file.

IIRC the recordcount property is not always valid without the query string. I'm not sure why it would be different between 32 bit and 64 bit though. In this case the word "may" was key, but I have seen ADO functions fail when the query string was not used. Even if it's just a Select * type

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

IIRC the recordcount property is not always valid without the query string. I'm not sure why it would be different between 32 bit and 64 bit though. In this case the word "may" was key, but I have seen ADO functions fail when the query string was not used. Even if it's just a Select * type

Hmmm...I wonder if this would differ if the local save format was ADTG (instead of XML)?

Paz, Could you check (with a Text Editor) if the local XML file has these two lines in the XML header?

xmlns:rs='urn:schemas-microsoft-com:rowset'

xmlns:z='#RowsetSchema'>

Share this post


Link to post
Share on other sites

Hmmm...I wonder if this would differ if the local save format was ADTG (instead of XML)?

Paz, Could you check (with a Text Editor) if the local XML file has these two lines in the XML header?

xmlns:rs='urn:schemas-microsoft-com:rowset'

xmlns:z='#RowsetSchema'>

I saved both in the default format (ADTG I guess) and attribute-based XML files (and I have the 2 lines mentionned), same results.

(For the XML output, I specify "1" as the second parameter, after the XML file path, in the .Save() method)

I did try to just do a $RST.Movelast right after I load the persistent recordset, but under Win64, .Recordcount is still "0"

On live database connexion (where I get my data that I then save as XML), with forward-only cursors, I would usually get "-1", which is the expected value when .recordcount property is not available.

But no need to spend too much energy on this... it's not really a big issue. For now, it just affects my program's display when it loads recordsets when running natively in 64bit...

I'm already surprized that 64bit ADO.Recordset works that good. Will sound stupid, but it's a plus for my database browser project (at work) that it works natively in 64bit. Managers like to hear that your work is more "future proof" because (insert-a-reason-here, like native 64bit) :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0