I have a global.asa file in classic asp that I'm trying to convert to global.asax to use with my asp.net site. Here's the code (minus the login info for security):
<SCRIPT LANGUAGE="VBScript" RUNAT="SERVER">
Sub Session_onStart()
dim auth_user,x,con,rst,sql,lefthdr
set con=Server.Createobject("ADODB.Connection")
Set rst= Server.CreateObject("ADODB.Recordset")
auth_user = ucase(request.servervariables("auth_user"))
x=len(auth_user)
if left(auth_user,9)="MYDOMAINNAME\" then auth_user=right(auth_user,x-9) end if
if left(auth_user,4)="ABC\" then auth_user=right(auth_user,x-4) end if
session("authuser")=auth_user
sql = "select num,name from mytable where userid='" & auth_user & "'"
con.open "Provider=SQLOLEDB; Data Source=mydatasource; Initial Catalog=mytable; User ID=myid; Password=xxxxxxx"
rst.open sql, con
if not rst.eof then
session("name") = rst("name")
session("num") = rst("num")
else
session("name") = ""
session("num") = ""
end if
rst.close
con.close
end Sub
Sub Session_onEnd()
Session("authuser")= Nothing
Session("name")= Nothing
Session("num")= Nothing
end Sub
</SCRIPT>
I've tried every which way I can imagine to find some examples on the web and I can't. How do I convert this info?
Joe W. Guy
Developer / DBA
<SCRIPT LANGUAGE="VBScript" RUNAT="SERVER">
Sub Session_onStart()
dim auth_user,x,con,rst,sql,lefthdr
set con=Server.Createobject("ADODB.Connection")
Set rst= Server.CreateObject("ADODB.Recordset")
auth_user = ucase(request.servervariables("auth_user"))
x=len(auth_user)
if left(auth_user,9)="MYDOMAINNAME\" then auth_user=right(auth_user,x-9) end if
if left(auth_user,4)="ABC\" then auth_user=right(auth_user,x-4) end if
session("authuser")=auth_user
sql = "select num,name from mytable where userid='" & auth_user & "'"
con.open "Provider=SQLOLEDB; Data Source=mydatasource; Initial Catalog=mytable; User ID=myid; Password=xxxxxxx"
rst.open sql, con
if not rst.eof then
session("name") = rst("name")
session("num") = rst("num")
else
session("name") = ""
session("num") = ""
end if
rst.close
con.close
end Sub
Sub Session_onEnd()
Session("authuser")= Nothing
Session("name")= Nothing
Session("num")= Nothing
end Sub
</SCRIPT>
I've tried every which way I can imagine to find some examples on the web and I can't. How do I convert this info?
Joe W. Guy
Developer / DBA