Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

This resource has not currently been approved, and is not currently linked to from our directory of resources. It is being displayed here for preview by the author and moderators only.
Rated
Read 6,902 times

Contents

    Database Manipulation with VB6 - Get Legacy Data

    sync_or_swim

    Get Legacy Data

    public Sub opendb()
    'Establish Connection with Database
    Set conConnection = New Connection
    With conConnection
    .Provider = " "
    .ConnectionString = "User ID= ;" & _
    "Password= ;" & _
    "Data Source= ;" & _
    "Persist Security Info=False"
    .Open
    End With
    End Sub
    Public Sub checkfields(norecs As Integer)
    'On Error GoTo ErrorHandler

    'Simple function to check if any fields in the recordset
    'are null, done to prevent run-time errors
    'A flag value of "1" denotes an error (NULL value), "0" is OK
    If rstRecordSet.Fields(0) = Null Then
    isanerror(1) = 1
    Else:
    For b = 0 To norecs
    If IsNull(rstRecordSet.Fields(b)) Then
    isanerror(b + 1) = "1"
    Else: isanerror(b + 1) = "0"
    End If
    Next b
    End If
    ErrorHandler:
    If Err.Number <> 0 Then Call writeerrorlog("checkfields ", "Unknown ", Err.Description, "")

    End Sub

    Public Sub checkfields2(norecs As Integer)
    'On Error GoTo ErrorHandler

    'Simple function to check if any fields in the recordset are null, done to prevent run-time errors
    'A flag value of "1" denotes an error (NULL value), "0" is OK
    If rstsubrecordset.Fields(0) = Null Then
    isanerror(1) = 1
    Else:
    For b = 0 To norecs
    If IsNull(rstsubrecordset.Fields(b)) Then
    isanerror(b + 1) = "1"
    Else: isanerror(b + 1) = "0"
    End If
    Next b
    End If
    ErrorHandler:
    If Err.Number <> 0 Then Call writeerrorlog("checkfields ", "Unknown ", Err.Description, "")

    End Sub

    Private Sub Command2_Click()
    On Error GoTo ErrorHandler
    Close #3
    Unload Me
    ErrorHandler:
    If Err.Number <> 0 Then Call writeerrorlog("command2click ", "Unknown ", Err.Description, "")

    End Sub

    Public Function writeerrorlog(ByVal badfunct, ByVal badref, ByVal badtext, ByVal badstate)

    Dim vno As String
    Dim errorsql As String
    Dim object As String
    badtext = Replace(badtext, "'", "''")
    badstate = Replace(badstate, "'", "''")

    vno = CStr(App.Major) & "." & CStr(App.Minor) & "." & CStr(App.Revision)
    object = App.Title

    Print #3, "Error" & "," & Now() & "," & badfunct & "," & badref & "," & object & "," & _
    vno & "," & badtext & "," & badstate

    Exit Function

    End Function

    Comments