Article View: borland.public.cppbuilder.database.ado
Article #4712Re: Retrieving an AutoIncrement field
From: Philip du Toit
Date: Mon, 19 Nov 2001 09:35
Date: Mon, 19 Nov 2001 09:35
43 lines
2127 bytes
2127 bytes
"Steve Clarke" <steve@h-a-s.co.za> wrote in message
news:Xns915E68F29D1CFstevehascoza19283746@207.105.83.65...
> Got a little problem here: I need to get to value of an autoincrement
after
> its posted.
>
> My previous method was something like this.
>
> using an ADOTable with the fields:
> AutoInc Table_ID;
> varchar(255) Description;
>
> my code would be something like this:
> ...
> table->Open();
> table->Insert();
> table->FieldByName("Description")->Value = "Test";
> table->Post();
> table->Refresh();
> int id = table->FieldByName("Table_ID")->AsInteger;
> ...
>
> This works ok most times. But on a large dataset the refresh method causes
> the calling app to hang...
>
> I've applied the ADO updates and CBuilder5 updates and still no joy.
>
> We are using MySQL via ODBC.
>
> I really hope someone can help with this as I am aging prematurely.
>
> Thanks,
> Steve Clarke.
Hi,
With MySQL one could get the last incremented value from a table by running
the following query:
SELECT LAST_INSERT_ID() FROM <tablename>
Regards
Philip du Toit
Technical Details
Message-ID:
<3bf8d305_1@dnews>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnewsReferences:
<Xns915E68F29D1CFstevehascoza19283746@207.105.83.65>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,7fd8fe9bf38091e0 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-11-19 01:39:08 PST Reply-To: "Philip du Toit" <philipd@scopetechnology.com> From: "Philip du Toit" <philipd@scopetechnology.com> Newsgroups: borland.public.cppbuilder.database.ado References: <Xns915E68F29D1CFstevehascoza19283746@207.105.83.65> Subject: Re: Retrieving an AutoIncrement field Date: Mon, 19 Nov 2001 11:35:23 +0200 Lines: 45 Organization: Scope Technologies X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 196.25.126.136 Message-ID: <3bf8d305_1@dnews> X-Trace: dnews 1006162693 196.25.126.136 (19 Nov 2001 01:38:13 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews