Article View: borland.public.cppbuilder.database.ado
Article #530ClientDataSet Insert with AutoInc field to Access Database
From: Bas Groeneveld
Date: Tue, 13 Sep 2005 08:45
Date: Tue, 13 Sep 2005 08:45
39 lines
2595 bytes
2595 bytes
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:
<4326917f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10698b,615b53151a82876e,start X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Bas Groeneveld" <nospam@nospam.com.au> Newsgroups: borland.public.cppbuilder.database.ado Subject: ClientDataSet Insert with AutoInc field to Access Database Date: Tue, 13 Sep 2005 18:45:58 +1000 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 NNTP-Posting-Host: 60.230.118.151 Message-ID: <4326917f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1126601087 60.230.118.151 (13 Sep 2005 01:44:47 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.spamkiller.net!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail