question about COM and ADO

Mark Hammond mhammond at skippinet.com.au
Tue Feb 1 07:08:13 EST 2000


Try:
rs.ActiveConnection.Value = None
?

Or just set rs itself to None...

Mark.

<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.





More information about the Python-list mailing list