question about COM and ADO

Geoff Talvola gtalvola at NameConnector.com
Tue Feb 1 15:55:04 EST 2000


Bill Tutt wrote:

> > -----Original Message-----
> > From: gtalvola at NameConnector.com [mailto:gtalvola at NameConnector.com]
> >
> [problems with translating the below VB code into Python]
> > > >     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
>
> Well according to build.py:
>                 # This is not the best solution, but I dont think there is
>                 # one without specific "set" syntax.
>                 # If there is a single PUT or PUTREF, it will function as a
> property.
>                 # If there are both, then the PUT remains a property, and
> the PUTREF
>                 # gets transformed into a function.
>                 # (in vb, PUT=="obj=other_obj", PUTREF="set obj=other_obj
> So, something like the following might work since, ActiveConnection does
> have a put and a putref functions:
> rs.SetActiveConnection(None)
>
> This code in Python
> rs.ActiveConnection = None
> Has the bogus VB equivalent of:
> rs.ActiveConnection = Nothing
> (i.e. no Set)
>
> The PUT vs. PUTREF distinction royally sucks.
>
> Bill

Unfortunately, this doesn't work either:

>>> rs.SetActiveConnection(None)
Traceback (innermost last):
  File "<pyshell#60>", line 1, in ?
    rs.SetActiveConnection(None)
  File "E:\Program
Files\Python\win32com\gen_py\00000201-0000-0010-8000-00AA006D2EA4x0x2x1.py",
line 1490, in SetActiveConnection
    return self._ApplyTypes_(0x3e9, 8, (24, 0), ((9, 1),),
'SetActiveConnection', None, arg1)
  File "E:\Program
Files\Python\win32com\gen_py\00000201-0000-0010-8000-00AA006D2EA4x0x2x1.py",
line 375, in _ApplyTypes_
    return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid,
LCID, wFlags, retType, argTypes) + args), user, resultCLSID)
TypeError: None is not a invalid interface object in this context

--


- Geoff Talvola
  Parlance Corporation
  gtalvola at NameConnector.com






More information about the Python-list mailing list