用vb 封装ADO的自定义类?
哪位高人做过用vb 封装ADO的自定义类?
给个实用的例子,我马上给分
[解决办法]
Public Function ExecRS(ByVal pCmd As String, pDCN As ADODB.Connection, Optional pAsync As Boolean = False) As ADODB.Recordset
Dim tmpRs As ADODB.Recordset
Set tmpRs = New ADODB.Recordset
If Not pAsync Then
tmpRs.Open pCmd, pDCN, adOpenForwardOnly, adLockReadOnly, adCmdText
Else
bCompleteExec = False
tmpRs.Open pCmd, pDCN, adOpenForwardOnly, adLockReadOnly, adAsyncExecute
Do While Not bCompleteExec
DoEvents
Loop
End If
Set ExecRS = tmpRs
Set tmpRs = Nothing
End Function
[解决办法]
哎!
[解决办法]
谢谢
[解决办法]
使用ADO对象操作数据库的函数:http://download.csdn.net/source/1498324
[解决办法]
呵呵,1楼也会给代码了
给lz个简单明了的
Public Function ExecuteSQL(ByVal sql As String) As ADODB.Recordset
Dim cn As ADODB.Connection, connstring As String
Dim rs As ADODB.Recordset
Set cn = New ADODB.Connection
connstring = "provider=Microsoft.Jet.OLEDB.4.0;Data source =" & App.Path & "/xs.mdb"
cn.ConnectionString = connstring
cn.Open
Set rs = New ADODB.Recordset
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
Set ExecuteSQL = rs
End Function
[解决办法]
Public Function GetRst(DataFile As String,TName As String) As ADODB.Recordset
Dim cn As New ADODB.Connection, constr As String
constr="provider=Microsoft.Jet.OLEDB.4.0;Data source =" & DataFile
cn.Open constr
Set getRst=cn.Execute("select * from " & TName)
End Function
[解决办法]
Public Function GetRst(DataFile As String,TName As String) As ADODB.Recordset
可是我要是把这个函数写在DLL 里,可是在DLL与主应用程序间不能传递ADO对象,总是出错
[解决办法]