Dim cnnmdb As ADODB.Connection
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"
a = cnnmdb.Execute("select top 1 from sheet1 order by CDate(T) desc")
b = cnnmdb.Execute("select top 1 from sheet1 order by CDate(T) asc")
在VB中如何查询数据库最早时间并且赋值给日期变量?我的数据库时间类型是文本的,初学,请教一下,谢谢!
答案:2 悬赏:0 手机版
解决时间 2021-02-04 13:46
- 提问者网友:战魂
- 2021-02-04 07:52
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-02-04 08:33
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("日期字段名"))
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("日期字段名"))
全部回答
- 1楼网友:杯酒困英雄
- 2021-02-04 09:48
'定义变量
dim access as new adodb.connection
dim res as new adodb.recordset
'连接数据库
access.connectionstring = "provider=microsoft.jet.oledb.4.0;" _
+ " data source=" + app.path + "\test.mdb; "
res.open "select * from test where 学号 = ‘001’", access, 1, 3
'取表中字段test
num=res.fields (test)
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯