提示错误
run - time error 430 class does not support Automation or does not suppot
expected interface
代码
'数据库
Private mConn As New ADODB.Connection
Private mRst As New ADODB.Recordset
Private Sub Form_Load()
Dim sSQL As String
mConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\db.mdb;"
mConn.Open
End Sub
run - time error 430 class does not support Automation or does not suppot
expected interface
代码
'数据库
Private mConn As New ADODB.Connection
Private mRst As New ADODB.Recordset
Private Sub Form_Load()
Dim sSQL As String
mConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\db.mdb;"
mConn.Open
End Sub
解决方案 »
- VB6.0中,数组参数在过程调用的问题:类型不匹配,缺少数组或用户定义类型
- 串口接收问题
- 高分求助大虾
- 在数据里记录里插进去了,不过出现提示错误,这是什么原因啊?高手进来看看!在线等
- 如何打印?
- 求购买VB下使用的32位XP图标
- 为什么会是这样啊,恐怖!!!!!!!!!!!!!
- 分割函数,突然记不起来了!
- 也许是初级问题,但请高手指点
- The process cannot access the file because it is being used by another process
- VB连接 sql server 2005 的时候,总是提示未知的连接错误?
- VB 如何使用移动通讯网站发短信
'需要安装OFFICE,在:工程-》引用中,添加:Microsoft Activex Data Object 2.x Library
'OFFICE的版本可以是2003,也可以是2007,建议2003
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:连接指定的数据库
'参数说明:cnnP:数据库连接对象;
' :adoP:数据集存储对象;
' :strPath:数据库路径;
' :strPassword:数据库密码;
'返回说明:True:连接成功 False:连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funConnectDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset, ByVal strPath As _
String, ByVal strPassword As String) As Boolean
On Error GoTo errFunction
Set cnnP = New ADODB.Connection
Set adoP = New ADODB.Recordset
cnnP.Provider = "Microsoft.Jet.OLEDB.4.0"
cnnP.Open "Data Source = " & strPath & ";jet oledb:database password=" & strPassword
funConnectDataBase = True
Exit Function
errFunction:
funConnectDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'函数功能:关闭数据库连接对象和数据文件的关联
'参数说明:cnnP:数据库连接对象;
' :adoP:数据库存储对象;
'返回说明:True:关闭连接成功 False:关闭连接失败
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Public Function funCloseDataBase(cnnP As ADODB.Connection, adoP As ADODB.Recordset) As Boolean
On Error GoTo errFunction
Set adoP = Nothing
Set cnnP = Nothing
funCloseDataBase = True
Exit Function
errFunction:
funCloseDataBase = False
End Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'过程功能:对指定的对象执行指定的SQL语句
'参数说明:cnnP:ADO连接对象
' :adoP:ADO记录集对象
' :strSql:SQL语句
' :bolQueryRecord:是否是查询记录集
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Public Sub subExcuteSQL(cnnP As ADODB.Connection, adoP As ADODB.Recordset, strSql As String, bolQueryRecord _
As Boolean)
If bolQueryRecord Then '如果是查询记录集
adoP.Open strSql, cnnP, adOpenStatic, adLockBatchOptimistic
Else
cnnP.Execute strSql
End If
End Sub
1、funConnectdatabase:连接数据库
2、subExcuteSql:执行sql查询
3、funClosedatabase:查询完毕,断开数据库连接
如果:
数据库路径 为 " & App.Path & "\db.mdb;"
没有密码
SQL = " Select * from aaa where id=1"
*.Fields("shu")
那么:
具体得怎么用,放在Form_Load中,text1.text中显示*.Fields("shu")
Private Sub Form_Load()
End Sub