🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
3 messages
3 total messages Started by Bas Groeneveld Tue, 13 Sep 2005 08:45
ClientDataSet Insert with AutoInc field to Access Database
#530
Author: Bas Groeneveld
Date: Tue, 13 Sep 2005 08:45
39 lines
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
Re: ClientDataSet Insert with AutoInc field to Access Database
#533
Author: Viatcheslav V. Vassiliev
Date: Tue, 13 Sep 2005 20:42
61 lines
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
>
>
> 
Re: ClientDataSet Insert with AutoInc field to Access Database
#584
Author: Bas Groeneveld
Date: Wed, 14 Sep 2005 14:19
37 lines
2535 bytes
Thanks for the information.

With that and a few hours trial and error I was able to get the
ClientDataSets working really well. The application can now create new
master and detail records (I don't use Master-Detail definitions on the
datasets but have 'rolled my own'), update the new data and then continue to
edit the new data with no errors.

This is better than a lot of applications based directly on ADO DataSets
(including some of my own) where master data often has to be saved before
detail records can be added.

If anyone is interested I would be happy to post details of the solution,
though with 20-20 hindsight and improved understanding I know realise that
the information was contained in the various articles and posts I had looked
at before. With the exception of Jet supporting the @@IDENTITY mechanism
that is.

Cheers
Bas

"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote in message
news:43273953$1@newsgroups.borland.com...
> 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)
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads