我在程序中作了一个查询按钮如下
Private Sub Cmdser_Click()
Dim str As Variant
If Text1.Text <> "" Then
str = "yhmc like '%" & Text1.Text & "%'"
End If
If Text2.Text <> "" Then
If str = "" Then
str = "yhkl like '%" & Text2.Text & "%'"
Else
str = str & " and yhkl like '%" & Text2.Text & "%'"
End If
End If
Adodc1.Recordset.Filter = str---------------错误指向这里
end sub
如果是这样的话,按钮是好用的而且能够查找到数据
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from companyuser order by xuhao"
Adodc1.Refresh
但是如果改成这个样子的话就会抱错:"在所对应的名称或序数集合中,未找到项目"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select xuhao as 序号,yhmc as 名称,yhkl as 密码,yhqx as 权限 ,js as 数值,lr as 录入人 from companyuser order by xuhao"
Adodc1.Refresh
还请各位高手指点指点
Private Sub Cmdser_Click()
Dim str As Variant
If Text1.Text <> "" Then
str = "yhmc like '%" & Text1.Text & "%'"
End If
If Text2.Text <> "" Then
If str = "" Then
str = "yhkl like '%" & Text2.Text & "%'"
Else
str = str & " and yhkl like '%" & Text2.Text & "%'"
End If
End If
Adodc1.Recordset.Filter = str---------------错误指向这里
end sub
如果是这样的话,按钮是好用的而且能够查找到数据
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from companyuser order by xuhao"
Adodc1.Refresh
但是如果改成这个样子的话就会抱错:"在所对应的名称或序数集合中,未找到项目"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select xuhao as 序号,yhmc as 名称,yhkl as 密码,yhqx as 权限 ,js as 数值,lr as 录入人 from companyuser order by xuhao"
Adodc1.Refresh
还请各位高手指点指点
解决方案 »
- 客户机上的mdac_typ的版本,应该装哪个版本呀?
- MSHFlexGrid 录入数据问题?
- 我想用VB来写一个串行通信,由于没得实际硬件所以就把电脑的串口的2,3脚直接短路来测试。但...
- 关于VB写标准DLL中的DllMain的问题
- 关于ActiveX的问题。
- 请教:VB6.0编写的数据库应用程序(使用了ADO技术),在没有安装VB的电脑上能运行吗?
- 100分问一个视频文件方面的问题
- VB中为System.TimeSpan类型的时间相减怎么转化为integer
- 我用directsound 的GetCurrentPosition总是报byref参数类型不合是为什么
- 请教:msflexgrid控件如何单独设定表格某一行的背景及前景颜色啊?(无内容)
- CSDN 快速搜索
- VB SSDT
你这里把数据集的列名用as做了别名 那么filter 过滤就根据别名来
If Text1.Text < > "" Then
str = "名称 like '%" & Text1.Text & "% '"
End If
If Text2.Text < > "" Then
If str = "" Then
str = "密码 like '%" & Text2.Text & "% '"
Else
str = str & " and 密码 like '%" & Text2.Text & "% '"
End If
End If
Adodc1.RecordSource = "select xuhao as 序号,yhmc as 名称,yhkl as 密码,
yhqx as 权限 ,js as 数值,lr as 录入人 from companyuser order by xuhao"
Adodc1.Refresh 我看没什么错误
有什么好处?