看了半天资料,最终做出来无法使用,高手给看看,自定义函数如下:
Function ADOSql(sql As String) As ADODB.Recordset
Set Con = New ADODB.Connection
Set rs = New ADODB.Recordset
With Con
.Provider = "SQLOLEDB"
.CommandTimeout = 5
.ConnectionTimeout = 10
.IsolationLevel = adXactCursorStability '设置隔离级别
End With
Con.Open "SERVER=192.168.1.200;Data=ERP;UID=sa;pwd="
rs.Open sql, Con, adOpenKeyset, adLockReadOnly
Set rsl = rs
End Function
Function ADOSql(sql As String) As ADODB.Recordset Dim Con As ADODB.Connection
Dim rs AS ADODB.Recordset
Set Con = New ADODB.Connection
Set rs = New ADODB.Recordset
With Con
.Provider = "SQLOLEDB"
.CommandTimeout = 5
.ConnectionTimeout = 10
.IsolationLevel = adXactCursorStability '设置隔离级别
End With
Con.Open "SERVER=192.168.1.200;Data=ERP;UID=sa;pwd="
rs.Open sql, Con, adOpenKeyset, adLockReadOnly
Set ADOSql = rs
End Function