为什么我的语句没能实现要求呢 问题出在那里
Dim StrSQL As String
StrSQL = "select * from rsxx where " '//给定义好的字符变量赋予SQL语句
'//判断单选框中时,判断姓名单选框选中时
If optname.Value = True Then
StrSQL = StrSQL & "员工姓名 = '" & Trim(txygname.Text) & "'"
'//判断单位单选框选中时
ElseIf optdanwei = True Then
StrSQL = StrSQL & "岗位 = '" & Trim(txygdanwei.Text) & "'"
'//判断岗位单选框选中时
ElseIf optgangwei = True Then
StrSQL = StrSQL & "岗位 = '" & Trim(txyggwei.Text) & "'"
'//判断学历单选框选中时
ElseIf optxueli = True Then
StrSQL = StrSQL & "学历 = '" & Trim(txygxueli.Text) & "'"
'//判断政治面貌单选框选中时
ElseIf optzzmm = True Then
StrSQL = StrSQL & "政治面貌 = '" & Trim(txzzmm.Text) & "'"
'//判断性别单选框选中时
ElseIf optsex = True Then
StrSQL = StrSQL & "性别 = '" & Trim(txsex.Text) & "'"
'//判断合同时间单选框选中时
ElseIf opthttime = True Then
StrSQL = StrSQL & "劳动合同日期 between #" & dtphetong1.Value & "# and #" & dtphetong2.Value & "#" & ""
If RsQRecord.State = adStateClosed Then
RsQRecord.Open StrSQL, DBCON, adOpenKeyset, adLockOptimistic, adCmdText
End If
Set dgrecord.DataSource = RsQRecord.DataSource
lblcount.Caption = RsQRecord.RecordCount '//将记录条数显示在标签上
dgrecord.Refresh '//刷新网格
RsQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
Else
If RstQRecord.State = adStateClosed Then
RstQRecord.Open "rsxx", DBCON, adOpenKeyset, adLockOptimistic, adCmdTable
End If
Set dgrecord.DataSource = RstQRecord.DataSource '//设置网格的数据源
lblcount.Caption = RstQRecord.RecordCount
dgrecord.Refresh '//刷新网格
RstQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
End If
Dim StrSQL As String
StrSQL = "select * from rsxx where " '//给定义好的字符变量赋予SQL语句
'//判断单选框中时,判断姓名单选框选中时
If optname.Value = True Then
StrSQL = StrSQL & "员工姓名 = '" & Trim(txygname.Text) & "'"
'//判断单位单选框选中时
ElseIf optdanwei = True Then
StrSQL = StrSQL & "岗位 = '" & Trim(txygdanwei.Text) & "'"
'//判断岗位单选框选中时
ElseIf optgangwei = True Then
StrSQL = StrSQL & "岗位 = '" & Trim(txyggwei.Text) & "'"
'//判断学历单选框选中时
ElseIf optxueli = True Then
StrSQL = StrSQL & "学历 = '" & Trim(txygxueli.Text) & "'"
'//判断政治面貌单选框选中时
ElseIf optzzmm = True Then
StrSQL = StrSQL & "政治面貌 = '" & Trim(txzzmm.Text) & "'"
'//判断性别单选框选中时
ElseIf optsex = True Then
StrSQL = StrSQL & "性别 = '" & Trim(txsex.Text) & "'"
'//判断合同时间单选框选中时
ElseIf opthttime = True Then
StrSQL = StrSQL & "劳动合同日期 between #" & dtphetong1.Value & "# and #" & dtphetong2.Value & "#" & ""
If RsQRecord.State = adStateClosed Then
RsQRecord.Open StrSQL, DBCON, adOpenKeyset, adLockOptimistic, adCmdText
End If
Set dgrecord.DataSource = RsQRecord.DataSource
lblcount.Caption = RsQRecord.RecordCount '//将记录条数显示在标签上
dgrecord.Refresh '//刷新网格
RsQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
Else
If RstQRecord.State = adStateClosed Then
RstQRecord.Open "rsxx", DBCON, adOpenKeyset, adLockOptimistic, adCmdTable
End If
Set dgrecord.DataSource = RstQRecord.DataSource '//设置网格的数据源
lblcount.Caption = RstQRecord.RecordCount
dgrecord.Refresh '//刷新网格
RstQRecord.Close '//关闭记录集
txygname.Text = Empty '//请空文本框
txygdanwei.Text = Empty
txyggwei.Text = Empty
txygxueli.Text = Empty
txzzmm.Text = Empty
txsex.Text = Empty
End If
解决方案 »
- 如何让程序调用的bat程序以最小化程序运行
- 在VBScript中动态创建ActiveX控件的实例时,如何获得它相应的事件呢?并且为什么我创建某些控件可以,而创建另外一些又不行,但其实这些
- 问题不难,为增加人气,进来就有分,散分!
- 第3次接着问!今天没解决!明天还问!
- 我要有一段长时间的预处理,在此过程,想让鼠标处于“忙”状态,怎样编程?
- 谁能制作类似vb中的属性框?
- 按比例分配总量后自动调整差异
- vb中文件保存的原代码是怎样的?
- 263zyf(控件)请进来,有分!
- 请问在VB中怎样实现分组且每页有组标头!
- 为什么这SQL句不对,是limit的问题吗
- vb OpenPrinter 调用老是返回0
提示说 说至少一个参数没有被指定
在 RstQRecord.Open "rsxx", DBCON, adOpenKeyset, adLockOptimistic, adCmdTable 这
一句
是什么问题导致的呢