Private Sub Command1_Click()
Dim pStatus As String
Dim a As String
a = Trim(Text1.Text)
Dim b As String
b = Trim(Text2.Text)
Dim c As String
c = Trim(Text3.Text)
Dim padoConnection As New ADODB.Connection
With padoConnection
.ConnectionString = "provider=microsoft.jet.oledb.4.0;persist security info=false;data source=" & App.Path & "\物品领用登记表.mdb"
.Open
If .State = adStateOpen Then
pStatus = "Connection is OK!"
Else
pStatus = "Connection is Failed!"
End If
End With
With Adodc1
.ConnectionString = padoConnection
.RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "'"
.LockType = adLockOptimistic
End With
Adodc1.Refresh
DoEvents
DataGrid1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
这个RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "
并没有错,显示所有记录,但是根据条件查询,没有任何变化请问哪里出了错。
Dim pStatus As String
Dim a As String
a = Trim(Text1.Text)
Dim b As String
b = Trim(Text2.Text)
Dim c As String
c = Trim(Text3.Text)
Dim padoConnection As New ADODB.Connection
With padoConnection
.ConnectionString = "provider=microsoft.jet.oledb.4.0;persist security info=false;data source=" & App.Path & "\物品领用登记表.mdb"
.Open
If .State = adStateOpen Then
pStatus = "Connection is OK!"
Else
pStatus = "Connection is Failed!"
End If
End With
With Adodc1
.ConnectionString = padoConnection
.RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "'"
.LockType = adLockOptimistic
End With
Adodc1.Refresh
DoEvents
DataGrid1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub
这个RecordSource = "select * from 物品领用登记表 where 领用人姓名 LIKE '%" + a + "%' and 物品名称 LIKE '%" + b + "%' and 数量 like '%" + c + "%'" + " and 领用日期 between '" + Text4.Text + "' and '" + Text5.Text + "
并没有错,显示所有记录,但是根据条件查询,没有任何变化请问哪里出了错。
解决方案 »
- VsMenu.ocx菜单控件怎样使其disabled
- 请问如何用数据库技术DAO、ADO直接打开Excel.xls文件?急!
- 有点难度的问题如何将图片保存成有透明通道的PSD或TIFF之类的文件格式,哪位大侠知道?请赐教
- VB怎么处理韩文?
- 用完全进销存源码(含文档)交换FLEXCELL注册码
- 图像在单选按钮下的显示问题,急
- 如何得知鼠标移出Treeview?具体情况请见帖子内容。
- 怎么才能做到在软件安装时象photoshop一样要求输入序列号?
- 过程太大,怎么办?大侠帮忙!
- 把VB的EXE转化为DLL,需要做什么?
- 用split怎么区分有多少个substring
- 请问怎么样把 '2005-1-4' 格式化成 '2005-01-04'?
用了like,可能用的都能查到所有记录吧
设定一个temp=select...语句,运行看看你的语句是否正确!
语句。这个却显示全部,不能根据条件来查询。这个语句是万能查询,输入为空表示全部,逐个条件输入也可以。该怎么解决,请大家帮忙啊!在线等待,谢谢大虾
如: LIKE '*" + a + "*'
Dim sql1,sql2,sql3,sql4
Dim a, b, c Sql = "select * from 物品领用登记表 where 1 = 1 "
If a <>"" Then sql1 = "and 领用人姓名 like '%"& a &"%' " Else sql1=""
If b <>"" Then sql2 = "and 物品名称 like '%"& b &"%' " Else sql2=""
......
Sql = Sql & sql1 & sql2 & sql3 & sql4
Adodc1.RecordSource=SQL注意语句之间要有空格
Set DataGrid1.DataSource = Adodc1