用户定义类型未定义 ??
Public Function executesql1(ByVal sql As String) As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As String
cmd = "provider=microsoft.jet.oledb.4.0;" & "data source=" & App.path & "\..\data\wrwtj.mdb;"
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
With cnn
.ConnectionString = cmd
.Open
End With
With rst
.Open sql, cnn, adOpenKeyset, adLockOptimistic
Set executesql1 = rst
End With
Set rst = Nothing
Set cnn = Nothing
End Function
我把这段代码放模块里边。。
为什么说第一句,用户定义类型未定义 ??
[解决办法]
ADO对象没有引用.在工程属性中引用一下即可.
[解决办法]
引用了吗?
[解决办法]
引用 microsoft activex data object ……
[解决办法]
1、确认ADO对象是否正确引用;
2、这段代码貌似有点问题,最后返回的结果会变成Nothing