<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
    sub Session_Start(sender as Object,e as EventArgs)
	'取得目前用户
	Session("nowUser")=Request.ServerVariables("REMOTE_HOST")
	dim f as string="server=localhost;uid=sa;database=Master"
	dim NowConn1 as SqlConnection = new SqlConnection(f)'连至Master资料库
	dim re as SqlCommand = new SqlCommand()
	re.Connection=NowConn1
	re.CommandText="sp_databases"
	re.CommandType = CommandType.StoredProcedure
	dim k as SqlDataReader
	re.Connection.Open()
	k=re.ExecuteReader()'执行名为sp_databases的StoreProcedure
	do until k.Read()=false
		if k.GetString(0)="Northwind" then
			dim a as string="server=localhost;uid=sa;"
			a+="database=Northwind"
			dim NowConn2 as SqlConnection = new SqlConnection(a)
			Session("NowSQLNor")=NowConn2
		elseif k.GetString(0)="StockSQL" then
			dim b as string="server=localhost;uid=sa;"
			b+="database=StockSQL"
			dim NowConn3 as SqlConnection = new SqlConnection(b)
			Session("NowSTKSQL")=NowConn3
		end if
	Loop
end sub
    sub Application_BeginRequest(sender as Object, e as EventArgs)
	DIM x as string=Request.ServerVariables("PATH_TRANSLATED")
	dim y as string=x.Remove(0,x.Length-11)
	if y="Usegbl.aspx" then
		Response.Write(Request.ServerVariables("REMOTE_HOST"))
        	Response.Write("执行请求中...<br>")
	end if
    end sub
    sub Application_EndRequest(sender as Object,e as EventArgs)
end sub
</script>

