vb6.0 Adodc 和 DataGrid 控件怎么编写查询语句,让查询结果显示在DataGrid1中?

以下是我的语句,系统说from子句错误,adodc无法refresh
Private Sub Command2_Click()
On Error GoTo xerr
Dim xh As String
Dim xm As String
If Option1.Value = True Then
xh = Text1.Text
Adodc1.RecordSource = "select * form 学生信息 where 学生姓名='" & xh & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
ElseIf Option2.Value = True Then
xm = Text1.Text
Adodc1.RecordSource = "select * form 学生信息 where 课程名='" & xm & "'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End If
Exit Sub
xerr:
MsgBox Err.Description, vbInformation, "提示"
End Sub

是From不是Form,关键词拼写错误。

Private Sub Command2_Click()
    On Error GoTo xerr
    Dim xh As String
    Dim xm As String
    If Option1.Value = True Then
        xh = Text1.Text
        Adodc1.RecordSource = "select * from 学生信息 where 学生姓名='" & xh & "'"
        Adodc1.Refresh
        Set DataGrid1.DataSource = Adodc1
    ElseIf Option2.Value = True Then
        xm = Text1.Text
        Adodc1.RecordSource = "select * from 学生信息 where 课程名='" & xm & "'"
        Adodc1.Refresh
        Set DataGrid1.DataSource = Adodc1
    End If
    Exit Sub
xerr:
    MsgBox Err.Description, vbInformation, "提示"
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-07-17
select * form 改成 select * from
from拼错了

相似回答