Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert global.asa to global.asax

Status
Not open for further replies.

jguy

IS-IT--Management
Nov 17, 2000
69
0
0
US
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
 
hi,

the problem is that this is in VBScript and ASP.NET requires VB.NET. only the structure is same, but you will have to do a couple of code changes to make this work...

Known is handfull, Unknown is worldfull
 
I'm not that experienced with VB, how would I convert this?

Joe W. Guy
Developer / DBA
 
hi,

you will have to read up first on how to connect to SQL Server in VB.NET.

you can find many sample codes on the net, other than that, the assigning of session and the event are basically the same...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top