我的查询语句 把结果放在datagrid中
为什么我的语句没能实现要求呢 问题出在那里
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
[解决办法]
看看提示错误出在哪里?