VB中语法错误 操作符丢失

来源:百度知道 编辑:UC知道 时间:2024/05/12 16:25:31
Private Sub cmdQuery_Click()
If OptBH.Value And Trim(cboCourID.Text) = "" Then
MsgBox "请选择课程编号!", vbOKOnly + vbInformation, "提示"
Exit Sub
End If
If OptName.Value And Trim(cboCourName.Text) = "" Then
MsgBox "请选择课程名称!", vbOKOnly + vbInformation, "提示"
Exit Sub
End If
Dim strSql As String
If OptBH.Value Then
strSql = "select * from 课程信息表 where 课程编号='" & Trim(cboCourID.Text) & "'" '按课程编号查询
Else
strSql = "select * from 课程信息表 where 课程名称='" & Trim(cboCourName.Text) & "'" '按课程名称查询
End If
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open strSql, cn, adOpenKeyset, adLockReadOnly
If rs.EOF Then
MsgBox "没有找到符合条件的记录!", vbOKOnly + vbInformation, "提示"
Else
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
End I

具体错误是什么你得贴出来,否则还得把你的程序测试一下,我这没有VB

Set rs = New ADODB.Recordset 这句上看,之前RS没有定义,前面加一句
dim rs as adodb.recordset
试试