怎么样根据DTPicker查找出数值!!~~连接数据库是没有问题的我用Text1可以查找出数值,我认为错误是红色部分没有将DTPicker的值转化成日期型,我换过'"+Trim(DTP1.Value)+"','"+str(DTP1.Value)+"'都不行,数据库里是日期型,请帮帮我吧,谢谢~~!!!!!!Private Sub Command2_Click()
Adodc1.Visible = False
Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\db1.mdb"'Adodc1.RecordSource = "select * from inf where name='" + Trim(Text1.Text) + "'"
Adodc1.RecordSource = "select * from inf where dat=Trim(DTP1.Value)"(数据库里是日期型)Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
If Not Adodc1.Recordset.EOF Then
With DataGrid1
.Columns(0).Width = 800
.Columns(1).Width = 2400
End WithEnd If
End Sub
Adodc1.Visible = False
Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\db1.mdb"'Adodc1.RecordSource = "select * from inf where name='" + Trim(Text1.Text) + "'"
Adodc1.RecordSource = "select * from inf where dat=Trim(DTP1.Value)"(数据库里是日期型)Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
If Not Adodc1.Recordset.EOF Then
With DataGrid1
.Columns(0).Width = 800
.Columns(1).Width = 2400
End WithEnd If
End Sub
语句自己写吧。
谢谢楼上
但我试过还是有问题
报错说:字符串语法错误,在查询表达式dat=#" & DTP1.Value & "# "中我真的是改过好多,我觉得是dat这个取值不对,sql句有问题。帮我改改,谢谢了~~