Hi
How to generate the number in the text box when the database table is empty while form is loaded
regards
bhuvana
Hi
How to generate the number in the text box when the database table is empty while form is loaded
regards
bhuvana
For (and following ’s request for details): the safest, simplest pattern is to let the database create the serial and read it back after the INSERT. That avoids race conditions when many users open the form at once. Typical flow: user edits -> on OK do the INSERT -> return the new id in the same operation -> display it. Database-specific return mechanisms include SQL Server’s OUTPUT or SCOPE_IDENTITY(), PostgreSQL’s RETURNING, and MySQL’s LAST_INSERT_ID().
If you must show a number when the form opens there are two common approaches, both with tradeoffs:
Examples (conceptual):
SELECT NEXT VALUE FOR dbo.DocSeq AS ReservedDocEntry; INSERT INTO Documents (...) OUTPUT inserted.DocEntry VALUES (...); INSERT INTO documents (...) VALUES (...);
SELECT LAST_INSERT_ID(); See official docs for details and correct behavior: SQL Server SEQUENCE and OUTPUT/SCOPE_IDENTITY and PostgreSQL RETURNING and MySQL AUTO_INCREMENT / LAST_INSERT_ID.
Jump to Post— crunchie 990What??
Post in the correct forum and explain in detail what you want and you may get the answer you seek :)
What??
Post in the correct forum and explain in detail what you want and you may get the answer you seek :)
Hi
i want to generate the serial number( for example DocEntry 1,2,3 ....) in the textbox when the form open. after that it should be saved in the database while ok button is clicked. and then next number should be generated in the text box.
regards
bhuvana
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.