ngaisteve1
07-29-2003, 05:03 AM
Just want to ask the logic to generate auto-generate no.
My system is inventory system. When user click submit requisition, the system will check if there is any running_no. This is for sometimes the user have a running_no but didn't continue for a minute. So, when he came in back, the same running no will still be used. But, if the user has been out for long period of time and then came in back and when user click the submit requisition button, a new auto-generated running_no will be assigned. I got this well work out. As mentioned, when user click submit requisition button, the system will check if there is any exiting running_no (alive session). If got a mesg will come out giving me 2 opt. Continue to existing one or close the existing one and start a new one. So, for close and start a new one, my logic is like below:
1. delete the existing running no (so that the db won't be flooded.
2. add new record where userid = session user id. the running no is primary key. so, it will be auto incremented.
3. then get this running no from the same record again.
Is this logic ok?
the 2nd and 3rd steps, I did it like below:
<%
rs.CursorLocation = 3
rs.Open "tbl_running_no", conn, 3, 3
rs.addnew
rs("emp_userid") = session("membername")
rs.update
session("sOldRunNo") = rs("running_no")
response.redirect "requisition_add_search.asp"
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
Problem is what come out when I click the second opt which is close and open new requisition form is 0. When I look at the db, it is not 0. I find this difficult to explain but I hope you all can understand. Big thanks for any reply.
My system is inventory system. When user click submit requisition, the system will check if there is any running_no. This is for sometimes the user have a running_no but didn't continue for a minute. So, when he came in back, the same running no will still be used. But, if the user has been out for long period of time and then came in back and when user click the submit requisition button, a new auto-generated running_no will be assigned. I got this well work out. As mentioned, when user click submit requisition button, the system will check if there is any exiting running_no (alive session). If got a mesg will come out giving me 2 opt. Continue to existing one or close the existing one and start a new one. So, for close and start a new one, my logic is like below:
1. delete the existing running no (so that the db won't be flooded.
2. add new record where userid = session user id. the running no is primary key. so, it will be auto incremented.
3. then get this running no from the same record again.
Is this logic ok?
the 2nd and 3rd steps, I did it like below:
<%
rs.CursorLocation = 3
rs.Open "tbl_running_no", conn, 3, 3
rs.addnew
rs("emp_userid") = session("membername")
rs.update
session("sOldRunNo") = rs("running_no")
response.redirect "requisition_add_search.asp"
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
Problem is what come out when I click the second opt which is close and open new requisition form is 0. When I look at the db, it is not 0. I find this difficult to explain but I hope you all can understand. Big thanks for any reply.