代码在global.asa中不起作用 [英] code doesn't work in global.asa

查看:54
本文介绍了代码在global.asa中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的login.asp中有代码将用户数据库中的在线字段设置为

true或1.我正在尝试使用global.asa中的相同代码将

在线字段更改为0但它不起作用。代码非常简单,它应该是b $ b工作,任何想法为什么它不是?


Sub Session_OnEnd

如果会话(QUOT; USER_ID")<>" "然后''检查用户是否已登录



ConnectionString =" Driver = {SQL

Server}; UID = emenworldcom2;密码= BBBBBB; DATABASE = Mydatabase; SERVER = 111.111

..111.11 \ i1"

设置Conn2Gallery = Server.CreateObject(" ADODB.Connection")

设置CmdTrackUser = Server.CreateObject(" ADODB.Recordset")

Conn2Gallery.Open ConnectionString

SQL.CommandText =" SELECT Users。* FROM Users WHERE(User_ID ="&

Session(" User_ID")&")"

SQL.CommandType = 1

设置SQL.ActiveConnection = Conn2Gallery

CmdTrackUser.Open SQL ,, 1,3

CmdTrackUser.Fields(" Online")= 0

CmdTrackUser.Update

CmdTrackUser.Close

设置CmdTrackUser = Nothing

Conn2Gallery.Close

设置Conn2Gallery =没什么

END IF

解决方案

硬编码UserID一次并尝试,看看Session()是否失败


-

Curt Christianson

所有者/首席开发人员,DF-Software
www。 Darkfalz.com

" Julian" < EP **** @ shaw.ca>在消息中写道

新闻:%2 *************** @ tk2msftngp13.phx.gbl ...



我的login.asp中有代码,它将用户数据库
中的在线字段设置为true或1.我试图在global.asa中使用相同的代码来更改
在线字段为0但它不起作用。代码非常简单,
应该可以工作,任何想法为什么它都没有?

Sub Session_OnEnd
如果Session(User_ID)<>" ; "然后''检查用户是否已登录

ConnectionString =" Driver = {SQL

Server}; UID = emenworldcom2;密码= BBBBBB; DATABASE = Mydatabase; SERVER = 111.111 .111.11 \ i1"
设置Conn2Gallery = Server.CreateObject(" ADODB.Connection")
设置CmdTrackUser = Server.CreateObject(" ADODB.Recordset")
Conn2Gallery .Open ConnectionString
SQL.CommandText =" SELECT Users。* FROM Users WHERE(User_ID ="&
Session(" User_ID")&")"
SQL .CommandType = 1
设置SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL ,, 1,3
CmdTrackUser.Fields(" Online")= 0
CmdTrackUser.Update < br> CmdTrackUser.Close
设置CmdTrackUser =没什么
Conn2Gallery.Close
设置Conn2Gallery =没什么
结束如果



你怎么知道它不起作用?你打电话给Session.Abandon看看它是否有效?
它有效吗?试试这段代码:


Sub Session_OnEnd()

CreateObject(" WScript.Shell")。运行" cmd.exe / c net send

YOUR_COMPUTER_NAME我正在运行",0,False

UserID =会话(" User_ID")

如果UserID<> ""然后

ConnectionString =" Driver = {SQL Server}; UID =" &安培; _

" emenworldcom2;密码= BBBBBB;" &安培; _

" DATABASE = Mydatabase; SERVER = 111.111.111.11\i1"

''''''获取oledb连接字符串

'''''''''''''''''''''''''''''''''''''''''''''$ $ $ $ $ $ $ $ $'$''''''''''''''''''''''''$ $ $ $ $ $ $ $ $ SET [Online] = 0 WHERE [UserID] =" &安培;用户ID

设置Conn2Gallery = Server.CreateObject(" ADODB.Connection")

Conn2Gallery.Open ConnectionString

Conn2Gallery.Execute SQL ,, 129

Conn2Gallery.Close:Set Conn2Gallery = Nothing

结束如果


结束Sub

Ray at home

" Julian" < EP **** @ shaw.ca>在消息中写道

新闻:%2 *************** @ tk2msftngp13.phx.gbl ...



我的login.asp中有代码,它将用户数据库
中的在线字段设置为true或1.我试图在global.asa中使用相同的代码来更改
在线字段为0但它不起作用。代码非常简单,
应该可以工作,任何想法为什么它都没有?

Sub Session_OnEnd
如果Session(User_ID)<>" ; "然后''检查用户是否已登录

ConnectionString =" Driver = {SQL

Server}; UID = emenworldcom2;密码= BBBBBB; DATABASE = Mydatabase; SERVER = 111.111 .111.11 \ i1"
设置Conn2Gallery = Server.CreateObject(" ADODB.Connection")
设置CmdTrackUser = Server.CreateObject(" ADODB.Recordset")
Conn2Gallery .Open ConnectionString
SQL.CommandText =" SELECT Users。* FROM Users WHERE(User_ID ="&
Session(" User_ID")&")"
SQL .CommandType = 1
设置SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL ,, 1,3
CmdTrackUser.Fields(" Online")= 0
CmdTrackUser.Update < br> CmdTrackUser.Close
设置CmdTrackUser =没什么
Conn2Gallery.Close
设置Conn2Gallery =没什么
结束如果



我遇到了同样的问题。

检查文件夹是否给出访问IIS进程帐户

(IWAM_yourmachinename)写入数据库。


Paolo

" Julian" < EP **** @ shaw.ca>在消息中写道

新闻:%2 *************** @ tk2msftngp13.phx.gbl ...



我的login.asp中有代码,它将用户
数据库中的在线字段设置为true或1.我试图在global.asa中使用相同的代码来更改
在线字段为0但它不起作用。代码非常简单,
应该可以工作,任何想法为什么它都没有?

Sub Session_OnEnd
如果Session(User_ID)<>" ; "然后''检查用户之前是否记录了

ConnectionString =" Driver = {SQL

Server}; UID = emenworldcom2;密码= BBBBBB; DATABASE = Mydatabase; SERVER = 111

..111 .111.11 \ i1"
设置Conn2Gallery = Server.CreateObject(" ADODB.Connection")
设置CmdTrackUser = Server.CreateObject(" ; ADODB.Recordset")
Conn2Gallery.Open ConnectionString
SQL.CommandText =" SELECT Users。* FROM Users WHERE(User_ID ="&
Session(" User_ID")& ;")"
SQL.CommandType = 1
设置SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL ,, 1,3
CmdTrackUser.Fields(" Online" )= 0
CmdTrackUser.Update
CmdTrackUser.Close
设置CmdTrackUser = Nothing
Conn2Gallery.Close
设置Conn2Gallery = Nothing
END IF



Hi

I have code in my login.asp which sets the online field in user database to
true or 1. I am trying to use the same code in global.asa to change back the
online field to 0 but it doesn''t work. The code is very simple and it should
work, any idea why it doesn''t?

Sub Session_OnEnd
If Session("User_ID")<>" " Then '' check if user has logged in
before.
ConnectionString = "Driver={SQL
Server};UID=emenworldcom2;Password=BBBBBB;DATABASE =Mydatabase;SERVER=111.111
..111.11\i1"
Set Conn2Gallery = Server.CreateObject("ADODB.Connection")
Set CmdTrackUser = Server.CreateObject("ADODB.Recordset")
Conn2Gallery.Open ConnectionString
SQL.CommandText = "SELECT Users.* FROM Users WHERE (User_ID = " &
Session("User_ID") & ")"
SQL.CommandType = 1
Set SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL, , 1, 3
CmdTrackUser.Fields("Online") = 0
CmdTrackUser.Update
CmdTrackUser.Close
Set CmdTrackUser = Nothing
Conn2Gallery.Close
Set Conn2Gallery = Nothing
END IF

解决方案

hard code the UserID once and try, to see if the Session() is what''s failing

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Julian" <ep****@shaw.ca> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Hi

I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn''t work. The code is very simple and it should work, any idea why it doesn''t?

Sub Session_OnEnd
If Session("User_ID")<>" " Then '' check if user has logged in
before.
ConnectionString = "Driver={SQL
Server};UID=emenworldcom2;Password=BBBBBB;DATABASE =Mydatabase;SERVER=111.111 .111.11\i1"
Set Conn2Gallery = Server.CreateObject("ADODB.Connection")
Set CmdTrackUser = Server.CreateObject("ADODB.Recordset")
Conn2Gallery.Open ConnectionString
SQL.CommandText = "SELECT Users.* FROM Users WHERE (User_ID = " &
Session("User_ID") & ")"
SQL.CommandType = 1
Set SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL, , 1, 3
CmdTrackUser.Fields("Online") = 0
CmdTrackUser.Update
CmdTrackUser.Close
Set CmdTrackUser = Nothing
Conn2Gallery.Close
Set Conn2Gallery = Nothing
END IF



How do you know it''s not working? Are you calling Session.Abandon to see if
it works? Try this code:

Sub Session_OnEnd()
CreateObject("WScript.Shell").Run "cmd.exe /c net send
YOUR_COMPUTER_NAME I''m running", 0, False
UserID = Session("User_ID")
If UserID <> "" Then
ConnectionString = "Driver={SQL Server};UID=" & _
"emenworldcom2;Password=BBBBBB;" & _
"DATABASE=Mydatabase;SERVER=111.111.111.11\i1"
''''''Get an oledb connection string at
''''''www.connectionstrings.com instead
''''''of using this ODBC one.
SQL = "UPDATE [Users] SET [Online]=0 WHERE [UserID]=" & UserID
Set Conn2Gallery = Server.CreateObject("ADODB.Connection")
Conn2Gallery.Open ConnectionString
Conn2Gallery.Execute SQL, ,129
Conn2Gallery.Close : Set Conn2Gallery = Nothing
End If

End Sub
Ray at home
"Julian" <ep****@shaw.ca> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Hi

I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn''t work. The code is very simple and it should work, any idea why it doesn''t?

Sub Session_OnEnd
If Session("User_ID")<>" " Then '' check if user has logged in
before.
ConnectionString = "Driver={SQL
Server};UID=emenworldcom2;Password=BBBBBB;DATABASE =Mydatabase;SERVER=111.111 .111.11\i1"
Set Conn2Gallery = Server.CreateObject("ADODB.Connection")
Set CmdTrackUser = Server.CreateObject("ADODB.Recordset")
Conn2Gallery.Open ConnectionString
SQL.CommandText = "SELECT Users.* FROM Users WHERE (User_ID = " &
Session("User_ID") & ")"
SQL.CommandType = 1
Set SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL, , 1, 3
CmdTrackUser.Fields("Online") = 0
CmdTrackUser.Update
CmdTrackUser.Close
Set CmdTrackUser = Nothing
Conn2Gallery.Close
Set Conn2Gallery = Nothing
END IF



I had the same problem.
Check and see if the folder give access to the IIS Process Account
(IWAM_yourmachinename) to write into the db.

Paolo
"Julian" <ep****@shaw.ca> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...

Hi

I have code in my login.asp which sets the online field in user database to true or 1. I am trying to use the same code in global.asa to change back the online field to 0 but it doesn''t work. The code is very simple and it should work, any idea why it doesn''t?

Sub Session_OnEnd
If Session("User_ID")<>" " Then '' check if user has logged in before.
ConnectionString = "Driver={SQL
Server};UID=emenworldcom2;Password=BBBBBB;DATABASE =Mydatabase;SERVER=111
..111 .111.11\i1"
Set Conn2Gallery = Server.CreateObject("ADODB.Connection")
Set CmdTrackUser = Server.CreateObject("ADODB.Recordset")
Conn2Gallery.Open ConnectionString
SQL.CommandText = "SELECT Users.* FROM Users WHERE (User_ID = " &
Session("User_ID") & ")"
SQL.CommandType = 1
Set SQL.ActiveConnection = Conn2Gallery
CmdTrackUser.Open SQL, , 1, 3
CmdTrackUser.Fields("Online") = 0
CmdTrackUser.Update
CmdTrackUser.Close
Set CmdTrackUser = Nothing
Conn2Gallery.Close
Set Conn2Gallery = Nothing
END IF



这篇关于代码在global.asa中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆