是的,我包裝了我的代碼,它工作得很好。我製作了這樣的實用功能:
Public Sub CloseRecordSet(ByRef recordSet As ADODB.Recordset)
Try
If recordSet.State = ADODB.ObjectStateEnum.adStateOpen Then
recordSet.Close()
End If
Catch ex As Exception
Dim funcName As String = System.Reflection.MethodInfo.GetCurrentMethod().Name
SV_DZS_Utils.PrintToConsole(funcName & ": " & ex.Message & ", Source: " & ex.Source & ", StackTrace: " & ex.StackTrace)
Finally
recordSet = Nothing
End Try
End Sub
Public Sub OpenRecordSetForwardReadOnly(ByRef recordSet As ADODB.Recordset, ByVal sql As String, ByRef dbConn As ADODB.Connection)
Try
recordSet.Open(sql, dbConn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText)
Catch ex As Exception
Dim funcName As String = System.Reflection.MethodInfo.GetCurrentMethod().Name
SV_DZS_Utils.PrintToConsole(funcName & ": " & ex.Message & ", Source: " & ex.Source & ", StackTrace: " & ex.StackTrace)
End Try
End Sub
Public Sub OpenRecordSetDynamic(ByRef recordSet As ADODB.Recordset, ByVal sql As String, ByRef dbConn As ADODB.Connection)
Try
recordSet.Open(sql, dbConn, ADODB.CursorTypeEnum.adOpenDynamic, , ADODB.CommandTypeEnum.adCmdText)
Catch ex As Exception
Dim funcName As String = System.Reflection.MethodInfo.GetCurrentMethod().Name
SV_DZS_Utils.PrintToConsole(funcName & ": " & ex.Message & ", Source: " & ex.Source & ", StackTrace: " & ex.StackTrace)
End Try
End Sub
是的,他們會拋出異常。所有的ADO方法都可以。 – GSerg
我建議在一個無害的環境下進行嘗試(如果行爲不像你期望的那樣,它不會造成任何「永久性」傷害)。 –
包裝打開是好的,dbase射擊到地獄,發生。關閉,呃,你將如何處理這個問題?不要這樣做。 –