I want update one record using ADO,but I can't ,why?
nightmarch
nightmarch at gmail.com
Tue Jan 25 22:06:51 EST 2005
Sorry, I mean this code line " rs.Supports( wc.constants.adUpdate ) "
got False result, So I can't update one record,i.e. I can't execute
this code "rs.Fields.Item(0).Value = 11".
And , if code is written like this:
##<code-------------------------
conn.Open(connStr )
rs.Open( tblName, conn, wc.constants.adOpenKeyset,
wc.constants.adLockOptimistic )
rs.Fields.Item(0).Value = 11
s.Update()
##>code-------------------------
I got error msg like following:
##<errorMsg----------------------------
self._oleobj_.Invoke(*(args + (value,) + defArgs))
com_error: (-2147352567, '\xb7\xa2\xc9\xfa\xd2\xe2\xcd\xe2\xa1\xa3',
(0, 'ADODB.Field', 'Current Recordset does not support updating. This
may be a limitation of the provider, or of the selected locktype.',
'C:\\WINNT\\HELP\\ADO210.CHM', 0, -2146825037), None)
##>errorMsg----------------------------
On Tue, 25 Jan 2005 10:25:00 -0800, Robert Brewer <fumanchu at amor.org> wrote:
> nightmarch wrote:
> > I want update one record ,but I can't ,why?
> >
> > code like following:
> >
> > ##-------------------------------------------------
> > import win32com.client as wc
> >
> > def main():
> > conn = wc.Dispatch(r'ADODB.Connection')
> > rs = wc.Dispatch(r'ADODB.Recordset')
> > connStr = "Provider=MSDAORA.1;Password=jmpower;User
> > ID=jmpower;Data Source=jmgis_agps3;Persist Security Info=True"
> > tblName = r'wjtmp'
> >
> > conn.Open(connStr )
> >
> > rs.Open( tblName, conn, wc.constants.adOpenKeyset,
> > wc.constants.adLockOptimistic )
> >
> > if rs.Supports( wc.constants.adUpdate ):
> > rs.Fields.Item(0).Value = 11
> > rs.Update()
> > else:
> > print "recordset can't update"
> >
> > rs.Close()
> > conn.Close()
> >
> > if __name__ == '__main__':
> > main()
> > ##-------------------------------------------------
>
> You almost give us enough information to help out ,but you don't quite
> ,why?
>
> What happens when you run the above? Is there any output? Error message?
>
> Does your update affect the membership of the record in the keyset?
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/
> htm/mdconkeysetcursors.asp
>
> Why are you using keysets at all?
>
>
> Robert Brewer
> MIS
> Amor Ministries
> fumanchu at amor.org
>
More information about the Python-list
mailing list