黄忠昌是无病往生吗:vb查询问题

来源:百度文库 编辑:高校问答 时间:2024/04/30 08:14:46
根据DTpicker里的日期查询怎么查.
If Text1.Text = "" And Text2.Text = "" And Combo1.Text = "" And DTpicker1.value <> "" Then
Adodc1.RecordSource = "select * from 维护表 where 申请日期 = " & DTPicker1.Value & ""
Adodc1.Refresh
上面的语句查出来是空的.怎么改

从DTpicker1.value <> "" 来看属字符类型,SQL中字符应用单引号标记,故代码改为:
If Text1.Text = "" And Text2.Text = "" And Combo1.Text = "" And DTpicker1.value <> "" Then
Adodc1.RecordSource = "select * from 维护表 where 申请日期 = '" & DTPicker1.Value & "'"
Adodc1.Refresh
END IF