我用ado连接数据库出现问题..dataGrid不显示查询结果.还报错...专家帮我哦
我用ado连接数据库,dataGrid也用到了.要求在dataGrid中显示查询结果...可是总报错误...
我原来代码如下:
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim r2 As New ADODB.Recordset
Dim cnb As New ADODB.Connection
Dim cstring As String
cstring = ";Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\文件\程序\小程序\db1.mdb;Persist Security Info=False"
If Combo1.Text = "编号" Then
Set cn = New ADODB.Connection
cn.Open cstring
Set r2 = New ADODB.Recordset
With r2
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Open "select * from table1 where 编号=" & Text1.Text, cn, adOpenDynamic, adLockOptimistic
End With
Set DBGrid1.DataSource = r2
End If
End Sub
错误是:
实时错误'430'
类不支持自动化或不支持期望的接口
希望有能力的朋友帮帮我..谢谢
我的MSN:lizhigang_88@hotmail.com