condstr = ""
If Text1.Text <> "" Then
If condstr = "" Then
condstr = "日期 like'" + Format(Text1.Text, "yyyy-mm-dd") + "'"
Else
condstr = condstr + "and 日期='" + Format(Text1.Text, "yyyy-mm-dd") + "'"
End If
End IfIf Combo2.Text <> "" Then
If condstr = "" Then
condstr = "姓名 like'" + Trim(Combo2.Text) + "'"
Else
condstr = condstr + "and 姓名 like'" + Trim(Combo2.Text) + "'"
End If
End IfIf condstr <> "" Then
Adodc1.RecordSource = "select * from t1 where " + condstr
Adodc1.Refresh
MsgBox Adodc1.Recordset.RecordCount '当我选择日期来查询时无记录,当选择姓名查询时有记录。当然只要有时间查询就无记录???
Else
Adodc1.RecordSource = "select * from t1"
Adodc1.Refresh
End If
我这两天为这个烦透了,不知为何?请高手帮忙啊?
If Text1.Text <> "" Then
If condstr = "" Then
condstr = "日期 like'" + Format(Text1.Text, "yyyy-mm-dd") + "'"
Else
condstr = condstr + "and 日期='" + Format(Text1.Text, "yyyy-mm-dd") + "'"
End If
End IfIf Combo2.Text <> "" Then
If condstr = "" Then
condstr = "姓名 like'" + Trim(Combo2.Text) + "'"
Else
condstr = condstr + "and 姓名 like'" + Trim(Combo2.Text) + "'"
End If
End IfIf condstr <> "" Then
Adodc1.RecordSource = "select * from t1 where " + condstr
Adodc1.Refresh
MsgBox Adodc1.Recordset.RecordCount '当我选择日期来查询时无记录,当选择姓名查询时有记录。当然只要有时间查询就无记录???
Else
Adodc1.RecordSource = "select * from t1"
Adodc1.Refresh
End If
我这两天为这个烦透了,不知为何?请高手帮忙啊?
解决方案 »
- 在MSDN里找到函数原型!但是要如何知道怎么在VB里声明它!比如GetMessage就没有写明!
- 只有文件扩展名,如何获取对应应用程序的图标?
- 假如有个嵌放网页的ActiveX控件,点击上面的按钮时弹出一个WinForm,这时,WinForm如何取得上一级的ActiveX控件对象呢?
- 关于颜色对话框
- 怎样把读写ini函数封装成类?
- 江湖告急--------打包后程序不能执行的问题
- 关于将查询结果生成报表的问题,请高手帮忙。谢谢!
- IOBJECTCONSTRUCT什么意思,我看了MSDN。无奈英文差
- 关于Format的一个小问题,谢谢!
- 请问DATAGRID控件是不是只能用ADO控件绑定呀?
- VB中如何启动同步处理!急!
- 怎样给应用程序设置类似win2000中"Ctrl+Alt+Del"键的功能?
不然就是没记录的,我也刚刚碰到这个事情
如果你那是一个视图的话,就用Convert函数转化一下就可以了
Convert(varchar(10),日期,21) like'" + Format(Text1.Text, "yyyy-mm-dd")
用这句看看
If Text1.Text <> "" Then
If condstr = "" Then
condstr = "日期 like " & Text1.Text & "%"
Else
condstr = condstr + "and 日期=#" + Format(Text1.Text, "yyyy-mm-dd") + "#"
End If
End If
如果用likes要帶%,如果用等號,在日期的前後用#sql server2000
If Text1.Text <> "" Then
If condstr = "" Then
condstr = "日期 like'" + Format(Text1.Text, "yyyy-mm-dd") + "'%"
Else
condstr = condstr + "and 日期='" + Format(Text1.Text, "yyyy-mm-dd") + "'"
End If
End If
employeepaytable.年月 = '" & 日期 & "'"
ACCESS数据库
employeepaytable.年月 = #" & 日期 & "#"
查询时主要是格式的问题
#号
我原来遇到过
我照书上 的例子用'
但实际查询出错
改为#
后成了