问题描述
我有桌子出勤有属性
[ID],[Engi_Profile_ID],[In_Date_Time],[Out_Date_Time],[Reason],[备注],[旗帜]
当我登录时,插入[int],[Engi_Profile_ID],[In_Date_Time],[In_Date_Only],
[原因],[备注],[旗帜]插入但是当会话到期时,会触发一个查询以进行更新,在哪里写它来触发更新查询是Global.asax页面还是web.config页面怎么做。
我知道我是什么做错了。
给我写回答。
我尝试了什么:
void Session_Start(对象发送者,EventArgs e)
{
HttpContext.Current.Session(Session_Name);
id = HttpContext.Current.Session.SessionID;
SqlCommand cmd1 = new SqlCommand(Update Attendence set Out_Date_Time ='+ DateTime.Now +',Flag ='关闭'where Engi_PRofile_ID ='+ txtID.Text +'和Flag ='打开'并替换(转换) (Nvarchar(20),In_Date_Only,106),'',' - ')=替换(转换(Nvarchar(20),gETDATE(),106),'',' - '),con);
cmd1.Parameters.AddWithValue(@ Engi_Profile_ID,txtID.Text.ToString());
}
i have table Attendance having attribute
[ID],[Engi_Profile_ID],[In_Date_Time],[Out_Date_Time],[Reason],[Remark],[Flag]
When i login it insert [int],[Engi_Profile_ID] , [In_Date_Time] ,[In_Date_Only] ,
[Reason],[Remark],[Flag] is inserted but when session expire then a query is fired for update where to write it to fire the update query is it Global.asax page or web.config page how to do it.
I know what i have done is wrong.
give me write answer.
What I have tried:
void Session_Start(object sender, EventArgs e)
{
HttpContext.Current.Session("Session_Name");
id = HttpContext.Current.Session.SessionID;
SqlCommand cmd1 = new SqlCommand("Update Attendence set Out_Date_Time='" + DateTime.Now + "', Flag='Close' where Engi_PRofile_ID='" + txtID.Text + "' and Flag='Open' and Replace(Convert(Nvarchar(20),In_Date_Only,106),' ','-')=Replace(Convert(Nvarchar(20),gETDATE(),106),' ','-')", con);
cmd1.Parameters.AddWithValue("@Engi_Profile_ID", txtID.Text.ToString());
}
这篇关于如何在ASP.NET中会话到期时运行更新查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!