本文介绍了如何检索上次登录的特定用户的第一个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从用户登录表中检索用户的最后一次登录。回溯上次登录日期的查询是什么..?

i want to retrive the last login of the user from user login table. What is the query to retrive last logged in date..?

推荐答案

using (SqlConnection con = new SqlConnection(strConnect))
    {
    con.Open();
    using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 loginDate FROM myTable WHERE useID = @ID ORDER BY loginDate DESC", con))
        {
        cmd.Parameters.AddWithValue("@ID", userId);
        DateTime lastLogin = (DateTime) cmd.ExecuteScalar();
        }
    }


这篇关于如何检索上次登录的特定用户的第一个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 19:15