能不能用SQL查询时,加一个时间条件,比如:
"select * from xx where "& DateTime.Now &" - activetime> xx时间"
就是“现在的时间”-“activetime里的时间”>“指定的时间”问一下……还有,用一下这类方法 Dim Conn As New OleDb.OleDbConnection
Dim Comm As New OleDb.OleDbCommand
Dim Reader As OleDb.OleDbDataReader
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & HttpContext.Current.Server.MapPath("data.mdb") & ";user id=;password=;persist security info=true;"
Conn.Open()
Comm.Connection = Conn
Comm.CommandText = "select * from members where id=" & uid
Reader = Comm.ExecuteReader怎么知道Reader有多少条记录……
"select * from xx where "& DateTime.Now &" - activetime> xx时间"
就是“现在的时间”-“activetime里的时间”>“指定的时间”问一下……还有,用一下这类方法 Dim Conn As New OleDb.OleDbConnection
Dim Comm As New OleDb.OleDbCommand
Dim Reader As OleDb.OleDbDataReader
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & HttpContext.Current.Server.MapPath("data.mdb") & ";user id=;password=;persist security info=true;"
Conn.Open()
Comm.Connection = Conn
Comm.CommandText = "select * from members where id=" & uid
Reader = Comm.ExecuteReader怎么知道Reader有多少条记录……
这里说的是,查寻表建立时间小于当前时间减去10天的数据
DataReader不能直接得到记录数,因为它是逐行访问的,你可以用一个计数器,每访问一行加一,最后才得到行数
能详细说明一下或几个例子吗?谢谢……
只是示例一下,去搜下datediff的参数就了解了
SELECT DATEDIFF(month, '2005-12-20', '2006-01-01')相差多少月
SELECT DATEDIFF(day, '2005-12-20', '2006-01-01')相差多少日select * from xx where datediff(day, activetime ,getdate()) > 10 取出与当前日期相差超过10天的