Jump to content

Need help with ADO Disconnected RecordSet Syntax


Recommended Posts

All,

According to this, I need to pass an equivalent to 'Nothing' into the ActiveConnection method of the RecordSet object. However, I'm having difficulty sending the proper parameter. Does anyone have any idea how to implement disconnected recordsets via AutoIt?

CODE
; ADO Constants

Global Const $ADOPENSTATIC = 3

Global Const $ADUSECLIENT = 3

Global Const $ADOPENFORWARDONLY = 0

Global Const $ADLOCKBATCHOPTIMISTIC = 4

; Open ADO DB Connection

Dim $sPath = "c:\temp_database.xls"

Dim $objConnection = ObjCreate( "ADODB.Connection" )

$objConnection.Provider = "Microsoft.Jet.OLEDB.4.0"

$objConnection.ConnectionString = 'Data Source="' & $sPath & '"; Extended Properties=Excel 8.0;'

$objConnection.Open

; Fill the Recordset

Dim $objRecordSet = ObjCreate( "ADODB.Recordset" )

Dim $strQuery = "SELECT * FROM Input"

$objRecordSet.CursorLocation = $ADUSECLIENT

$objRecordSet.Open( $strQuery, $objConnection, $ADOPENFORWARDONLY, $ADLOCKBATCHOPTIMISTIC )

$objRecordSet.MoveFirst()

; =========== FAILED ATTEMPTS BELOW =============

Global Const $NULL_ZERO = 0

Global Const $NULL_STRING = ""

Global Const $NULL_DEFAULT = Default

;~ $objRecordSet.ActiveConnection = $NULL_ZERO

;~ $objRecordSet.ActiveConnection = $NULL_STRING

;~ $objRecordSet.ActiveConnection = $NULL_DEFAULT

;~ $objRecordSet.ActiveConnection = 0

;~ $objRecordSet.ActiveConnection = ""

;~ $objRecordSet.ActiveConnection = Default

; ===============================================

$objRecordSet.ActiveConnection = ; ????????

$objConnection.Close()

; If successful, we should retrieve a value

ConsoleWrite( $objRecordSet(0).Value & @CRLF)

Edited by zfisherdrums
Link to comment
Share on other sites

All my forum searches used "ADO" instead of ADOR. This would explain why I didn't stumble upon your blatantly obvious post before. Thanks! I'll be looking at your example more in depth.

Please note that the uploaded file on that post is returning a Board Message indicating that it might not be there any longer. I'll assume for now that the code block is the same.

Zach...

Link to comment
Share on other sites

Thanks for doing that. I downloaded it and ran into a few problems that I believe are stemming from the new AutoIt version.

Despite your post's self-effacing intro, your code is easy to follow logically. I realize your intent was to provide a springboard - which it succeed in.

My context differs slightly in that I must connect to an existing data store, fill the data set, then disconnect. I believe the heart of the issue is the lack of a NULL in AutoIT. This is assuming there isn't another way to produce a NULL value or some other blatant language feature I've glossed over.

If you ( or any readers within eye-shot ) know of a way to produce NULL values, I'd love to see it.

Thanks again for your help.

Zach...

Link to comment
Share on other sites

@

I don't think that an "$objConnection.ActiveConnection" can be blank or 0 ?!

the activeconnection can only after it's been defined $objConnection.Open(" ..." ) or "$objConnection.Close()"

When you want to use a DISCONNECTED recordset from an active connection,

you will have to use the ADOR.

The way it should be done is you open a ADODB.connection AND a ADOR.RecordSet simultaniously.

Then you read the records of the ADODB and fill them in the ADOR.RecordSet.

Then you close the ADODB.connection prperly.

And you will end up with a DISCONNECTED recordSet in de ADOR dataset.

Look here for an example on how to fill a ADOR with some data from something else

Disconnected RecordSet

regards,

ptrex

Edited by ptrex
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...