Thursday, July 30, 2009

How to auto increment id in access database based on a condition and save the id consecutively in asp.net?

In a form there are 3 text boxes - assetid, quantity, amount. When i enter 3 in the quantity and click a save button, assetid should auto increment from com1 to com2,com3,com4 consecutively in access database column and at the same time the amount should be divided equally among the 3 assetid and saved in the database.

How to auto increment id in access database based on a condition and save the id consecutively in asp.net?
I cannot imagine why you would want to implement such a design.





However, create a variable to hold the result of the dividing the amount by the quantity. Next, use a FOR/NEXT loop based upon the quantity entered. In the loop insert a record into the database. Access will automatically increment the assetid field, so you only need to provide the result of the amount/quantity operation by using the variable calculated at the beginning of the process.


No comments:

Post a Comment