question about COM and ADO
gtalvola at NameConnector.com
gtalvola at NameConnector.com
Tue Feb 1 14:41:35 EST 2000
More information about the Python-list mailing list
Tue Feb 1 14:41:35 EST 2000
- Previous message (by thread): question about COM and ADO
- Next message (by thread): question about COM and ADO
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <N0Al4.4439$E5.9681 at news-server.bigpond.net.au>, "Mark Hammond" <mhammond at skippinet.com.au> wrote: > Try: > rs.ActiveConnection.Value = None > ? > > Or just set rs itself to None... > > Mark. > That doesn't work either. Executing rs.ActiveConnection.Value = None gives the following error: Traceback (innermost last): File "<pyshell#39>", line 1, in ? rs.ActiveConnection.Value = None File "E:\Program Files\Python\win32com\gen_py\00000201-0000-0010-8000-00AA006D2EA4x0x2x1 .py", line 389, in __setattr__ raise AttributeError, attr AttributeError: Value And setting the recordset to None isn't an option because I then can't use the recordset object. The idea here is that ADO has the concept of creating a client-side recordset (hence the CursorLocation=adUseClient) based on a database connection. All of the data is immediately loaded from the database server when you call rs.Open. Then, by setting the recordset's ActiveConnection property to Nothing, you disconnect the recordset from the database connection. Then you can sort it, filter it, edit it, persist it, and so forth without being connected to the database server. The adLockBatchOptimistic part means that all changes to the recordset are saved locally within the Recordset object, but are not committed to the database until you re-connect to the database (by setting rs.ActiveConnection to a valid Connection object) and then call rs.UpdateBatch(). This all works fine from VB, but I can't figure out the magic needed to get it to work with Python. > <gtalvola at NameConnector.com> wrote in message > news:86t965$vlq$1 at nnrp1.deja.com... > > I'm using ADO from Python, and I'm having a problem figuring out > > how to do the equivalent of the VB code > > > > Dim cnn as New ADODB.Connection > > cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=c:\db1.mdb" > > dim rs as New ADODB.Recordset > > rs.CursorLocation = constants.adUseClient > > rs.Open "SELECT * FROM Table1", cnn, adOpenStatic, > > adLockBatchOptimistic > > set rs.ActiveConnection = Nothing > > > > in Python. I'm trying to create a disconnected client-side > recordset, > > which requires that after I open the recordset, I set its > > ActiveConnection property to Nothing (at least that's how it's done > in > > VB). I can't figure out the equivalent in win32com. In particular, > it > > chokes if I try to set it to None: > > > > >>> from win32com.client import * > > >>> cnn = Dispatch('ADODB.Connection') > > >>> cnn.Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data > Source=c:\db1.mdb" > > ) > > >>> rs = Dispatch('ADODB.Recordset') > > >>> rs.CursorLocation = constants.adUseClient > > >>> rs.Open( "SELECT * FROM Table1", cnn, > > constants.adOpenStatic,constants.adLockBatchOptimistic ) > > >>> rs.ActiveConnection = None > > Traceback (innermost last): > > File "<pyshell#8>", line 1, in ? > > rs.ActiveConnection = None > > File "E:\Program > > > Files\Python\win32com\gen_py\00000201-0000-0010-8000-00AA006D2EA4x0x2x > 1 > > .py", line 390, in __setattr__ > > apply(self._oleobj_.Invoke, args + (value,) + defArgs) > > com_error: (-2146825287, 'OLE error 0x800a0bb9', (0, > 'ADODB.Recordset', > > 'The application is using arguments that are of the wrong type, are > out > > of acceptable range, or are in conflict with one another.', '', 0, > > -2146825287), None) > > > > > > Anyone have an idea of how to do this? > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > Sent via Deja.com http://www.deja.com/ Before you buy.
- Previous message (by thread): question about COM and ADO
- Next message (by thread): question about COM and ADO
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list