Article View: borland.public.cppbuilder.database.ado
Article #533Re: ClientDataSet Insert with AutoInc field to Access Database
From: Viatcheslav V. Vassiliev
Date: Tue, 13 Sep 2005 20:42
Date: Tue, 13 Sep 2005 20:42
61 lines
3535 bytes
3535 bytes
Access, at least Jet 4 through OLEDB/ADO, supports select @@identity. However it would be good to test how it works in multi-user mode (or with multiple TADOConnections to the same db) because of lazy writes implemented in Access. //------------------------------------------ Regards, Vassiliev V. V. http://www.managed-vcl.com - using .Net objects in Delphi for Win32 + ADO.Net http://www.oledbdirect.com - The fastest way to access MS SQL Server, MS Jet (Access) and Interbase (through OLEDB) "Bas Groeneveld" <nospam@nospam.com.au> �������/�������� � �������� ���������: news:4326917f@newsgroups.borland.com... >I have a question which has been raised many times already: How to get the > value of the autoinc field after an update from a ClientDataSet? > > I have read many of the posts in this and the delphi newsgroups, as well > as > the articles on BDN, eg the one by Dan Miser. > > The basic thrust seems to be that in absence of any other methods the > Refresh method of the ClientDataSet should do the trick. > > Unfortunately I cannot get anything to work with an application I am > developing with a Microsoft Access database backend. > > Essentially I have an ADOQuery, a DataSetProvider and a ClientDataSet all > linked together. I insert the new record into the ClientDataSet, enter > some > data on a form into database controls linked to the ClientDataSet via a > DataSource, then issue the ApplyUpdates. The record is correctly inserted > into the table, however when I do a Refresh the record in the > ClientDataSet > is cleared. I presume this is because the Provider is unable to locate the > correct record in the database for some reason. > > I have also played around with various combinations of integer fields and > autoinc fields, ProviderFlags on both the ADOQuery and the ClientDataSet > persistent fields, Options and UpdateMode on the DataSetProvider - all to > no > avail. > > Using Access I cannot use SQL Server's SELECT @@IDENTITY in an > AfterUpdateRecord event or InterBase's Generator in a BeforeUpdateRecord > event. > > Am I missing something obvious here? > > Thanks > - > > ========================================== > Bas Groeneveld > Benchmark Design System and Software Engineering > PO Box 165N, Ballarat North, VIC 3350 > Phone: +61 3 5333 5441 Mob: 0409 954 501 > > >
Technical Details
Message-ID:
<43273953$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4326917f@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,615b53151a82876e X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <4326917f@newsgroups.borland.com> Subject: Re: ClientDataSet Insert with AutoInc field to Access Database Date: Wed, 14 Sep 2005 00:42:08 +0400 Lines: 63 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2670 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 85.93.138.132 Message-ID: <43273953$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1126644051 85.93.138.132 (13 Sep 2005 13:40:51 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!mpls-transit-01.news.qwest.net!38.119.100.82.MISMATCH!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail