根据系统日期显示登录历史记录. [英] Display Login history according to System date.

查看:53
本文介绍了根据系统日期显示登录历史记录.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据系统日期显示登录历史记录.
====================================== <= >
嗨FRNDS!

我具有用户的登录历史记录,UserLogin详细信息和UserLogout详细信息.

在GRIDVIEW中,它显示所有记录.但记录无法正确显示.

我需要在第一行中进行最近几分钟的登录,而在GRIDVIEW的首页中需要今天的用户登录历史记录.

注意:根据Date Wise,它应该显示在GRIDVIEW中.

这是我的代码:
==================

Display Login history according to System date.
===============================================

Hi FRNDS !!

I have Login history of the User, UserLogin details and UserLogout Details.

In GRIDVIEW it shows all the Records. but the REcords are not displaying correctly.

I need the last Few minutes login in the First row and todays users login history in the first page of GRIDVIEW.

Note : according to Date Wise it should display in GRIDVIEW.

This is my code :
==================

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;

public partial class Users_UserLoginHistory : System.Web.UI.Page
{
    string conString = ConfigurationManager.ConnectionStrings["KKIA_RUHConnectionString"].ToString();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridData();
        }
    }


    protected void BtnSearch_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(conString);


        SqlCommand cmd = new SqlCommand("Select LogId,UserName,Login_Time,Logout_Time from UserLogs where UserName='" + TxtSearch.Text + "' order by Login_Time desc", con);

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        Grid1.DataSource = dt;
        Grid1.DataBind();
    }


    private void GridData()
    {
        SqlConnection con = new SqlConnection(conString);

        SqlCommand cmd = new SqlCommand("Select LogId,UserName,Login_Time,Logout_Time from UserLogs order by Login_Time desc", con);

        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        Grid1.DataSource = dt;
        Grid1.DataBind();

    }
}



请帮帮我,

谢谢.



Please help me,

Thanks.

推荐答案



这里有些事情要牢记:
1)当您存储登录时间时,您将传递dateTime.现在,该机器的datetime应该是正确的,
2)在数据库中运行查询,并检查是否使用值正确进行排序.
3)如果您在SQL Server中使用日期函数,则该时间应与Windows时间(有时为ppl)同步.在系统或服务器中设置不正确,会导致日期,以不同的格式存储,并且用户最终会遇到此类问题
Hi,

There are certain things to keep in mind here:
1) when you store login time you will pass dateTime.Now, that machine datetime, should be proper,
2) run the query in the DB and check, whether sorting happening properly with the values.
3) if you are using Date function in SQL Server then, that should be in sync with windows time, sometime ppl. don''t set properly in the system or in the server, resulting the date, get stored in different formats and user end up in this kind of problems


这篇关于根据系统日期显示登录历史记录.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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