When a user completes a form, s/he can complete up to 5 records at a time.
If the the user completes 1 record, the ID increments by 1.
However, when a user completes more than 1 record, we would expect the ID to increment by as many records as the user completed.
For instance, let’s say user with ID 2516 completes 3 records, we would expect to see something like:
ID User
1 2516
2 2516
3 2516
If another user by id of 4874 completes 2, we would be:
ID User
4 4874
5 4874
etc
In stead, the value of ID is incrementing by only 1 no matter how many new records one particular user enters.
I know this is based on the code below.
Can you please help me fix it in such that the value increments based on how many records a particular user submits.
We don’t want to use identity seed to increment it.
Your help, as usual, is highly appreciated.
sql += "INSERT INTO Emp (UserSequence, employee_id, charity_code, check_amt, chcknum, one_time, bi_weekly, cash, donate_choice, date_stamp) "
sql += "VALUES ((select isNull(max(UserSequence), 0) + 1, '" & Replace(employee_idLabel.Text, "'", "''") & "','" & Replace(dedval.SelectedValue, "'", "''") & "','" & Replace(chckval.Text, "'", "''") & "','" & Replace(chcknumval.Text, "'", "''") & "','" & Replace(onetimeval.Text, "'", "''") & "','" & multival.Text & "','" & Replace(cashval, "'", "''") & "','" & Replace(donatechoice.SelectedItem.Value, "'", "''") & "','" & Replace(datestamp, "'", "''") & "');"
well this is rather your business logic.
I would recommend you the followin structure
and do insert statements like this.
It does exactly what you need. You leave your primary key as is but add another column that serves for your business logic.
EDIT
By the way, your VB.Code looks very cumbersome.
With ORM your code would look something like this.