🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Colin B Maharaj Wed, 05 Jul 2006 01:14
Auto Increment Field in MySQL
#302
Author: Colin B Maharaj
Date: Wed, 05 Jul 2006 01:14
36 lines
2447 bytes
Hi all, firstly I have began to move an application done
without any SQL system to a Relation Database model.

I created my own storage systems, caching systems, sorting systems
and formatting engines for my applications, I even created my own
web interface, with web engine built into my EXE, I then used the
SSL interceptors in Indy9 to make my web interface secure.

Now I am moving this to the web (again),
but this time using MYSQL, Apache, PHP (initially).

So what is my question......
I have just coded a routine using an ADOConnection to connect
to a MySQL database via an ODBC alias, then send data to one of the 
tables using the ADOCommand component.

This is fine except I have an auto-increment field but anytime
I close my application and reopen it, the auto increment field starts 
back from '1'.

here is my table....

CREATE TABLE event ( recid  int(9) DEFAULT "0" NOT NULL AUTO_INCREMENT,
                      eventid tinyint(4),
                      pcdate datetime NOT NULL default "2000-01-01 
00:00:00",
                      user varchar(12),
                      eventtext varchar(32),
                      PRIMARY KEY (pcdate, recid)
                    );

what I was hoping was that recid would auto increment to have something 
like a record number. But it keeps reseting to '1' after you disconnect 
and reconnect (or close / start) the application.

Any help will be appreciated.....
Re: Auto Increment Field in MySQL
#320
Author: Steve
Date: Wed, 02 Aug 2006 10:20
22 lines
1532 bytes
Hi Colin,

[ .. ]

> This is fine except I have an auto-increment field but anytime
> I close my application and reopen it, the auto increment field starts back 
> from '1'.
>
> here is my table....
>
> CREATE TABLE event ( recid  int(9) DEFAULT "0" NOT NULL AUTO_INCREMENT,
>                      eventid tinyint(4),
>                      pcdate datetime NOT NULL default "2000-01-01

[ ... ]

Did you have try to put away the DEFAULT to the recid autoincrement 
variable?
Is compatible a default value to a variable that is handled directly by the 
database engine ?

Steve
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