BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Retrieving AutoIncrement Field Value

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Ian Davies
Guest





PostPosted: Wed Aug 27, 2003 10:49 am    Post subject: Retrieving AutoIncrement Field Value Reply with quote




I am using a Postgres database accessed via the BDE and ODBC
and am trying to retrieve the value of a field that is
automatically incremented by the database server when a new
record is posted.

I have a very simple table consisting only of an id and name
fields. I have made my fields persistent and am using the
following code: -

Table1.Append;
Table1Name.AsString := 'test';
Table1.Post;
ShowMessage(Table1ID.AsString);

When I run this, the ID is always an empty string. I have set
the AutoGenerateValue of the ID field to arAutoInc but it still
doesn't work. I have moved the ShowMessage into the OnAfterPost
event handler but still no joy. I have even specifically called
UpdateCursorPos on the Dataset which, again, did not work.

Can anyone please help as this seems to be an awfully common
thing to achieve?

Thank you in advance.

Ian.


Back to top
klaus kuhl
Guest





PostPosted: Wed Dec 31, 2003 3:39 pm    Post subject: Re: Retrieving AutoIncrement Field Value Reply with quote



Select Max(ID) from tab


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.