在VB中如何查询数据库最早时间并且赋值给日期变量?我的数据库时间类型是文本的,初学,请教一下,谢谢!

2024-11-09 10:28:34
推荐回答(1个)
回答1:

Dim cnnmdb As ADODB.Connection
dim rs1 as recordset
Dim a As Date
Dim b As Date
Set cnnmdb = New ADODB.Connection
cnnmdb.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\110.mdb;Persist Security Info=False"
set rs1=cnnmdb.Execute("select top 1 * from sheet1 order by CDate(T) desc")
a =CDate( rs1("日期字段名"))
set rs1 = cnnmdb.Execute("select top 1* from sheet1 order by CDate(T) asc")
b =CDate( rs1("日期字段名"))