vb6.0 Adodc 和 DataGrid 控件怎么编写查询语句,让查询结果显示在DataGrid1中?
以下是我的语句,系统说from子句错误,adodc无法refreshPrivateSubCommand2_Click()OnErrorGoToxerrDimxhAsStr...
以下是我的语句,系统说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 展开
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 展开
2个回答
推荐于2018-03-22 · 知道合伙人软件行家
关注
展开全部
是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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询