Public Function Test() As Recordset
Dim cn As New Connection
Dim rs As New Recordset
cn.Open "driver={SQL Server};server=localhost;database=pubs;uid=sa;pwd="
rs.CursorLocation = adUseClient
rs.CursorType = adOpenStatic
rs.LockType = adLockReadOnly
rs.ActiveConnection = cn
rs.Open "select * from Employee", cn
Set Test = rs
End Function
客户端EXE调用代码
Private ox As New MyVB_COM.COMClass
Private rs As New Recordset
Private Sub Form_Load()
Set rs = ox.Test()
End Sub