Using Session...hot to do that?
My application wants user to register himself on first page and then it transfers it to second page wherein he has to fill-up employee information.So,I've written this code to generate company-id which wud then be assigned to that particular company like this--
strSQL="SELECT MAX(CompanyId)+1 as maxval FROM MASTER"
Set objRs=objConn.execute(strSQL)
CompanyId=objRs("maxval")
response.write "company-id=" &CompanyId
If IsNull(CompanyId) then
CompanyId = 1
End If
'SET VARIABLES FROM FORM
company_name=request.form("cname")
company_location=request.form("clocation")
company_function=request.form("cfunction")
company_core_bsns=request.form("ccbsns")
company_ceo=request.form("cceo")
I am taking values of the other variables from html code written above to this asp code.
after the insert query I am redirecting the user to next page named emp_info1.asp this way--
response.redirect "emp_info1.asp"
On emp_info1.asp , m tryin to generate employee-id by using same sql query I used for generating Company-id.It is working fine.But now the problem is that I want to insert this employee-id along with other details and Company-id too , in the employee table.I am using this query for generating employee-id ---
strSQL="SELECT MAX(EmpId)+1 as maxval FROM EMPLOYEE WHERE CompanyId='" & str & "'"
Set objRs=objConn.execute(strSQL)
EmpId=objRs("maxval")
Now the problem is that I've tried every possible method to get the value of company-id from previous page.But the value of company-id that is being inserted in database each time is 0.This means form is not getting value for company-id from previous page.I tried both form methods- get and post. I also tried session's concept. But nothing seems to be working. I think session concept wud be gud because it wud be helpful in implementing checks on further pages of my website.But m not so clear with it.
What I did to implement session's concept is that I wrote this stmt in global.asa--
Sub Session_OnStart()
session("id")=CompanyId
End Sub
Sub Session_OnEnd()
End Sub
then on first page where I want user to get registered, I assigned company-id generated in session variable like this--
session("id")=request.form("cid")
and on second page where I am retrieving company-id from previous page, I wrote--
str=session("id")
But even after all this, m unable to get company-id value in str from previous page.
What shud I do now??? Can anyone help???
|