dongli147 2006-11-1 14:21
vb的连接数据库问题.我用ado连接.出来毛病..大师快帮我
我用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
dongli147 2006-11-1 14:23
VB使用ADO连接数据库access出现问题..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
benliu00123 2007-10-23 13:04
出现一样的问题,楼主解决了没有啊?怎么解决的啊?
期望高手可以指点一下啊
benliu00123 2007-11-7 08:26
把Set DBGrid1.DataSource = r2改成set datagrid1.datasource=r2试试