home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 February / CHIP_2_98.iso / software / pelne / optionp / rds.cab / vbbusobjcls.cls < prev    next >
Text File  |  1997-08-14  |  2KB  |  62 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "VbBusObjCls"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Option Explicit
  11.  
  12. Private Sub Class_Initialize()
  13.   'class setup code here
  14. End Sub
  15.  
  16. Public Function Test()
  17.   'this is here to test minimum functionality
  18.   Test = "Functional test verified."
  19. End Function
  20.  
  21. Public Function GetMachineName() As String
  22.   'this is here to show that not all methods need to be database related
  23.   On Error GoTo ehGetMachineName
  24.   Dim pc_name As String * 255
  25.   Dim x As Long
  26.   x = GetComputerName(pc_name, 255)
  27.   GetMachineName = Trim(pc_name)
  28.   Exit Function
  29. ehGetMachineName:
  30.   GetMachineName = ""
  31. End Function
  32.  
  33. Public Function ExecuteSQL(ByVal Connect As String, ByVal SQL As String) As Long
  34.   'this function executes and SQL string and returns the number of records affected
  35.   On Error GoTo ehExecuteSQL
  36.   Dim objADOCn As New ADODB.Connection    'ADO must be registered locally
  37.   objADOCn.Open Connect                'open connection
  38.   objADOCn.BeginTrans                     'begin a transaction
  39.   objADOCn.Execute SQL, ExecuteSQL     'recordsetAffected is returned
  40.   objADOCn.CommitTrans                    'no errors, commit
  41. Exit Function
  42. ehExecuteSQL:
  43.   'if transactions is not committed, it will be rolled back
  44.   ExecuteSQL = -2                         '-2 indicates error condition
  45. End Function
  46.  
  47. Public Function GetRecordset(ByVal Connect As String, ByVal SQL As String) As ADOR.Recordset
  48.   'this function returns an ADODB recordset object
  49.   On Error GoTo ehGetRecordset
  50.   Dim objADORs As New ADODB.Recordset                      'ADO must be registered locally
  51.   objADORs.CursorLocation = adUseClientBatch               'this property is not visible in v1.0 typelib
  52.   objADORs.Open SQL, Connect, adOpenUnspecified, adLockBatchOptimistic, adCmdUnspecified
  53.   Set GetRecordset = objADORs                              'set object pointer for ADOR type recordset
  54. Exit Function
  55. ehGetRecordset:
  56.   Err.Raise Err.Number, Err.Source, Err.Description
  57. End Function
  58.  
  59. Private Sub Class_Terminate()
  60.   'class cleanup code here
  61. End Sub
  62.