普通车床实训心得体会:vb查询问题

来源:百度文库 编辑:神马品牌网 时间:2024/05/08 01:48:53
根据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