When I use MSSQL and I want to get the next auto number, I use some lines of code, this will save my record and tell me what the auto record number is and then I can use this to save into other records. Steve
-----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Glenn B. Lawler Sent: 04 October 2005 16:45 To: '[email protected]' Subject: RE: [delphi-en] Re: ADO Batch updates and master detail relationships > Using the max(invoiceno) method has worked for me quite well for > desktop applications. However, I'm developing client/server (MS SQL > Server) and my fear is that users will be colliding when they > retrieve the same invoiceno and try to save. Virtually all the work we do is with Client/Server databases. That is why I mentioned the "transaction capability". A transaction is a group of statements sandwiched between a BEGIN TRANSACTION and ended with either a COMMIT TRANSACTION or ROLLBACK TRANSACTION. All the statements within the transaction are rolled back (or undone) if errors occur. This tranaction feature is one of the primary features that defines a full RDBMS. Furthermore, a transaction is a single unit of work, meaning no other user can make any changes to the database until your transaction is complete. This is one of the reasons it is important to design your transactions so they complete quickly. Another feature of a Client/Server RDBMS is that they "serialize" transactions. So, if you execute a number of statements in a SQL batch, such as finding the next InvoiceNo, followed by inserting the record, you can be guaranteed no other user will be able to be doing this on the same table at the same time. Given these features, there is really no need to store the keys in a table. Glenn Lawler ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links ------------------------ Yahoo! Groups Sponsor --------------------~--> Most low income households are not online. Help bridge the digital divide today! http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/i7folB/TM --------------------------------------------------------------------~-> ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

