Results 1 to 5 of 5

Thread: What the h*ll is "Error 3146: ODBC Call Failed"?

  1. #1
    Guest
    i'm connected to a valid system DSN, i have the correct username and password, and yet i still get that error.

    halp, anybody. i beg of you good samaritans.

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Going to need a bit more information I think...

    Are you using DAO, ADO, OLE DB. Is it an Access DB or SQL Server?

    If you can post some sample code that is failing that may help.
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    Guest
    Crispin is right. However, this happens to me all the time over my network. Anything that cuases the system to grab the database will lock you out (backups, especially).

    Good Luck
    DerFarm


  4. #4
    Guest
    we're using this third party software called Ascent Capture, which scans documents, gives them indexes and then releases them into a SQL Server database. but whenever we get to the part where the app releases the documents, it returns error 3146.

    the company that made the app gave us the source code for the release script, but so far i can't see anything wrong. here's the module on database connection on release:

    Code:
    Option Explicit
    
    ' ReleaseData object set by the release controller.
    ' This object is to be used during the document release
    ' process as it will contain the document data and the
    ' external data source information defined during the
    ' setup process.
    Public DocumentData As ReleaseData
    
    Private oDB As New DatabaseFile
    
    Private Const M_RELEASE = "Database Release Script"
    Private bOpen As Boolean
    
    '*************************************************
    ' CloseScript
    '-------------------------------------------------
    ' Purpose:  Script release point.  Perform any
    '           necessary cleanup such as releasing
    '           resources, etc.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  One of the following:
    '             KFX_REL_SUCCESS, KFX_REL_ERROR,
    '             KFX_REL_FATALERROR, KFX_REL_REINIT
    '             KFX_REL_DOCCLASSERROR,
    ' Notes:    Called by the Release Controller
    '           once just before the script object
    '           is released.
    '*************************************************
    Public Function CloseScript() As KfxReturnValue
            On Error GoTo Err_CloseScript
            
            ' Assume success for now
            CloseScript = KFX_REL_SUCCESS
    
            If (Not bOpen) Then
                GoTo Exit_CloseScript
            End If
    
    Exit_CloseScript:
    100     Set oError.DataObject = Nothing
            bOpen = False
            Exit Function
    
    Err_CloseScript:
    110     Call oError.LogTheError(Err, Err.Description, M_RELEASE + ":" + Err.Source, Erl, False, False)
            CloseScript = KFX_REL_ERROR
            Resume Exit_CloseScript
    
    End Function
    
    '*************************************************
    ' OpenScript
    '-------------------------------------------------
    ' Purpose:  Script initialization point.  Perform
    '           any necessary initialization such as
    '           logging in to a remote data source,
    '           allocating resources, etc.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  One of the following:
    '             KFX_REL_SUCCESS, KFX_REL_ERROR,
    '             KFX_REL_FATALERROR, KFX_REL_REINIT
    '             KFX_REL_DOCCLASSERROR,
    ' Notes:    Called by the Release Controller
    '           once when the script object is loaded.
    '*************************************************
    Public Function OpenScript() As KfxReturnValue
            
            On Error GoTo Err_OpenScript
            
    800     Set oError.DataObject = DocumentData
    810     oError.TitleString = LoadResString(TITLE_RELEASEERROR)
    
            OpenScript = KFX_REL_SUCCESS
            bOpen = True
            
    Exit_OpenScript:
            Exit Function
    
    Err_OpenScript:
    820     Call DocumentData.LogError(Err, 0, 0, Err.Description, M_RELEASE + ":" + Err.Source, Erl)
            OpenScript = KFX_REL_ERROR
            Resume Exit_OpenScript
    
    End Function
    
    '*************************************************
    ' ReleaseDoc
    '-------------------------------------------------
    ' Purpose:  Document release point.  Use the
    '           ReleaseData object to release the
    '           current document's data to the
    '           external data repository.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  One of the following:
    '             KFX_REL_SUCCESS, KFX_REL_ERROR,
    '             KFX_REL_FATALERROR, KFX_REL_REINIT
    '             KFX_REL_DOCCLASSERROR,
    ' Notes:    Called by the Release Controller once
    '           for each document to be released.
    '*************************************************
    Public Function ReleaseDoc() As KfxReturnValue
        
            If (Not bOpen) Then
                ReleaseDoc = KFX_REL_ERROR
                GoTo Exit_ReleaseDoc
            End If
        
            On Error GoTo Err_ReleaseDoc
    
            oDB.ErrorLineNum = 0
    1040    Call oDB.SetupForDocuments(DocumentData)
    
            ' Release the images (operates differently if PDF selected)
            Dim oPdfRel As New PDFRel ' Coordinates PDF release process
            Dim strImageFilePath As String
            If oPdfRel.ReleaseEnabled(DocumentData) Then
                ' If PDF enabled, let the PDF module release the images.
    1050        strImageFilePath = oPdfRel.ReleaseImages(DocumentData)
            Else
                ' Let Ascent release the images.
    1060        Call DocumentData.ImageFiles.Copy
    1070        strImageFilePath = DocumentData.ImageFiles.ReleasedDirectory
            End If
            
            ' Release the full-text OCR.
            If (DocumentData.TextFilePath <> "") Then
    1080        Call DocumentData.TextFiles.Copy
            End If
        
            ' Release the index information to the Database
    1090    Call oDB.ReleaseIndexes(DocumentData, strImageFilePath)
     
           ReleaseDoc = KFX_REL_SUCCESS
    
    Exit_ReleaseDoc:
            Exit Function
    
    Err_ReleaseDoc:
            Dim iLine As Integer
            Dim nErrNum As Long
            Dim sErrDesc As String
            
            ReleaseDoc = KFX_REL_ERROR
            
            If (oDB.ErrorLineNum <> 0) Then
                iLine = oDB.ErrorLineNum
            Else
                iLine = Erl
            End If
            nErrNum = Err
            sErrDesc = Err.Description
            
            Call oError.LogTheError(nErrNum, sErrDesc, M_RELEASE + ":" + Err.Source, iLine, False, False)
                    
            Call DocumentData.SendMessage(sErrDesc, nErrNum, KFX_REL_DOC_ERROR)
            
            Resume Exit_ReleaseDoc
    
    End Function
    
    '*************************************************
    ' Class_Initialize
    '-------------------------------------------------
    ' Purpose:  VB calls this event when an object
    '           of this class is instantiated.  We
    '           simply initialize the variables.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Private Sub Class_Initialize()
        bOpen = False
    End Sub
    this is the code for the database setup:
    Code:
    Option Explicit
    
    Const M_DBCLASS = "Database Class"
    
    ' If the database is locked we will try to
    ' access it a pre-defined number of times
    Const MAX_WRITE_ATTEMPTS = 20
    
    '==================
    ' DAO Error Codes
    '==================
    ' -- Locked Database Messages --
    Const DAO_ERR_ReadConflictM As Long = 3186
    Const DAO_ERR_ReadConflict As Long = 3202
    Const DAO_ERR_CommitConflictM As Long = 3187
    Const DAO_ERR_CommitConflict As Long = 3624
    Const DAO_ERR_WriteConflictM As Long = 3260
    Const DAO_ERR_WriteConflict As Long = 3218
    Const DAO_ERR_RecordLocked As Long = 3158
    Const DAO_ERR_FileLockingUnavailable As Long = 3050
    Const DAO_ERR_DatabaseLocked As Long = 3006
    Const DAO_ERR_TableInUse As Long = 3009
    Const DAO_ERR_FileShareViolation As Long = 3045
    Const DAO_ERR_FileLockViolation As Long = 3046
    
    ' -- Error Messages --
    Const DAO_ERR_DataConvert As Long = 3421
    Const DAO_ERR_NameNotFound As Long = 3265
    Const DAO_ERR_KeyDuplicate As Long = 3022
    Const DAO_ERR_DatabaseReadOnly As Long = 3027
    
    '==================
    ' Local Variables
    '==================
    'Dim grsIndexTable As Recordset
    'Dim grsDocTable As Recordset
    
    '===================
    ' Global Variables
    '===================
    Public DBConnection As Database
    Public oWorkSpace As Workspace
    Public oDbEngine As New PrivDBEngine
    Public Connected As Boolean
    Public strIndexTableName As String
    Public strDocTableName As String
    
    ' -- Current DB connection settings --
    Public CurrentDBType As Integer
    Public ConnString As String
    Public ConnSysMDB As String
    Public ConnUser As String
    Public ConnPassword As String
    
    Public CurrentITable As String
    Public CurrentDTable As String
    
    Public ErrorLineNum As Integer
    
    '*************************************************
    ' ConnectToDatabase
    '-------------------------------------------------
    ' Purpose:  This routine will establish a
    '           connection to the passed in database.
    ' Inputs:   ConnType        Database Type
    '           ConnectString   Connection string -
    '                           could be the Access
    '                           database filename or
    '                           the DSN.
    '           UserName        username
    '           Password        password
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    This routine will close the current
    '           database connection if one exists
    '*************************************************
    Public Sub ConnectToDatabase(ByVal ConnType As Integer, _
                            ByVal ConnectString As String, _
                            ByVal SystemMDB As String, _
                            ByVal UserName As String, _
                            ByVal Password As String)
        Dim DBFilename As String
        Dim DBOptions As String
        Dim sPassword As String
        Dim nWriteAttempts As Integer
        
        On Error GoTo CTD_LogAndPropError
        
            ' If we are already connected to a database
            ' with the same settings, just exit
            If Connected = True And _
               CurrentDBType = ConnType And _
               ConnString = ConnectString And _
               ConnSysMDB = SystemMDB And _
               ConnUser = UserName And _
               ConnPassword = Password Then
                Exit Sub
            End If
                    
            ' If we are connected to a database,
            ' close the database before continuing
    500     Call CleanUpDBConnection
            Connected = False
            
            ' Build the proper connection string.  If ODBC, the
            ' options line of the OpenDatabase method accepts the
            ' connection string.  If Access, just pass in the
            ' filename
            sPassword = Password
            Select Case ConnType
                Case DBTYPE_ACCESS
                    DBFilename = ConnectString
                    If (Len(UserName) = 0 And Len(Password) <> 0) Then
                        DBOptions = ";PWD=" + Password
                        sPassword = ""
                    Else
                        DBOptions = ""
                    End If
                    If (UserName = "") Then
                        UserName = "Admin"
                    Else
                        UserName = UserName
                    End If
                    If (Len(SystemMDB) <> 0) Then
    510                 oDbEngine.SystemDB = SystemMDB
                    End If
                    
                Case DBTYPE_ODBC
                    DBFilename = ""
                    DBOptions = "ODBC;DSN=" & ConnectString & ";UID=" & UserName & ";PWD=" & Password
                    UserName = "Admin"
                    sPassword = ""
                    
                ' Add new database type here
                'Case DBTYPE_NEWTYPE
                
                Case Else
                    ' Invalid Database type
    520             Err.Raise ERR_BADDBTYPE, M_DBCLASS, LoadResString(MSG_BADDBTYPE)
                    
            End Select
                    
            ' Handle UserName and Password.
    530     Set oWorkSpace = oDbEngine.CreateWorkspace("Test", UserName, sPassword)
                
            ' Attempt to connect ...
            On Error GoTo CTD_DBOpenError
            nWriteAttempts = 1
    540     Set DBConnection = oWorkSpace.OpenDatabase(DBFilename, False, False, DBOptions)
            
    CTD_Success:
            ' We are connected
            Connected = True
            
            ' Remember the current DB settings
            CurrentDBType = ConnType
            ConnString = ConnectString
            ConnSysMDB = SystemMDB
            ConnUser = UserName
            ConnPassword = Password
            
            Exit Sub
            
    '---------------
    ' Error Handler
    '---------------
    CTD_DBOpenError:
            ' The database may be locked by another process.
            ' Retry the defined number of times.
            If DatabaseIsLocked() And nWriteAttempts < MAX_WRITE_ATTEMPTS Then
                nWriteAttempts = nWriteAttempts + 1
                Resume
            End If
            ' Drop through to the next error handler
    
    CTD_LogAndPropError:
            ' There is a problem with an Access 95/97 database and a 14 character password.
            ' In Access, the 14th character is treated as a NOP.  It does not matter to access
            ' what that character is or even if that character exist in the password.  In DAO, it DOES.
            ' So this work around will work even if MS fixes it.
                
            ' If there are 14 characters in the password and we are trying to connect to
            ' an Access database and there is an error then try using the first 13
            ' characters as a password.  If not throw the error.
            If (ConnType = DBTYPE_ACCESS) Then
                If (Len(DBOptions) = 19) Then
                    DBOptions = left(DBOptions, 18)
                    Resume
                End If
            End If
    
            ' Remember the line number of the error
            If (ErrorLineNum = 0) Then
                ErrorLineNum = Erl
            End If
            
            ' Let the caller deal with the error.
            Call Err.Raise(Err, M_DBCLASS + ".ConnectToDatabase:" + Err.Source, Err.Description)
            Exit Sub
    
    CTD_CreateWsFailed:
            Exit Sub
    End Sub
    
    '*************************************************
    ' ParseODBCString
    '-------------------------------------------------
    ' Purpose:  This routine will search for an
    '           ODBC connection string flag and
    '           pass back it's value.
    ' Inputs:   ConnectStr    full connection string
    '           TagVal        the tag to search for
    ' Outputs:  None
    ' Returns:  The value associated with the tag.
    ' Notes:    None
    '*************************************************
    Function ParseODBCString(ConnectStr As String, _
                                TagVal As String) As String
        Dim StartLoc As Integer
        Dim Length As Integer
        
            On Error GoTo POS_LogAndPropError
            
            ' First search the string for the tag value
            ' Tag value examples ("DSN", "PWD", etc.)
    550     StartLoc = InStr(UCase$(ConnectStr), UCase$(TagVal))
            
            ' If the tag was found, extract the value following the '='.
            If StartLoc <> 0 Then
    560         StartLoc = InStr(StartLoc, ConnectStr, "=") + 1
                ' If no '=' then we have no data to return.
                If (StartLoc <> 0) Then
                    ' Value end at either a ';' or the end
                    ' of the string
    570             Length = InStr(StartLoc, ConnectStr, ";")
                    If Length = 0 Then
                        Length = Len(ConnectStr) + 1
                    End If
                    ' Determine the number of characters in the value
                    Length = Length - StartLoc
                    ' Watch out for zero length
                    If (Length = 0) Then
                        ParseODBCString = ""
                    Else
    580                 ParseODBCString = Mid$(ConnectStr, StartLoc, Length)
                    End If
                Else
                    ParseODBCString = ""
                End If
            Else
                ' String was not found.
                ParseODBCString = ""
            End If
            
            Exit Function
            
    '---------------
    ' Error Handler
    '---------------
    POS_LogAndPropError:
            
            ParseODBCString = ""
            
    End Function
    
    '*************************************************
    ' SetupForDocuments
    '-------------------------------------------------
    ' Purpose:  This routine creates the connection to
    '           the database and builds the recordsets
    '           for the index and documents table.
    ' Inputs:   TheData     ReleaseData object
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Sub SetupForDocuments(TheData As ReleaseData)
            
            On Error GoTo SFD_LogAndPropError
            
            ' First establish the connection to the database,
            ' then create the record sets to the two tables
            ' we'll need to update
            With TheData
    1000        Call ConnectToDatabase(.CustomProperties(KEY_CONTYPE).Value, _
                                        .ConnectString, _
                                        .CustomProperties(KEY_SYSTEMMDB).Value, _
                                        .UserName, _
                                        .Password)
    '1010        Set grsIndexTable = DBConnection.OpenRecordset(.TableName)
    '1020        Set grsDocTable = DBConnection.OpenRecordset(.CustomProperties(KEY_DOCTABLE).Value)
                strIndexTableName = .TableName
                strDocTableName = .CustomProperties(KEY_DOCTABLE).Value
            End With
            Exit Sub
            
    '---------------
    ' Error Handler
    '---------------
    SFD_LogAndPropError:
            ' Remember the line number of the error
            If (ErrorLineNum = 0) Then
                ErrorLineNum = Erl
            End If
            
            ' Let the caller deal with the error
            Call Err.Raise(Err, M_DBCLASS + ".SetupForDocuments:" + Err.Source, Err.Description)
            
    End Sub
    
    '*************************************************
    ' ReleaseIndexes
    '-------------------------------------------------
    ' Purpose:  This is the main that releases the
    '           document indexes to the database.
    ' Inputs:   The release data object
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Sub ReleaseIndexes(TheData As ReleaseData, ByVal strImageFilePath As String)
        
            On Error GoTo RI_LogAndPropError
    
            oWorkSpace.BeginTrans
            
            ' Release DocPath and DocID to documents table
    1050    Call ReleaseDocTable(TheData, strImageFilePath)
            
            ' Release Data to Index Table
    1060    Call ReleaseIndexTable(TheData.Values)
    
            oWorkSpace.CommitTrans
            
            Exit Sub
            
    '---------------
    ' Error Handler
    '---------------
    RI_LogAndPropError:
            oWorkSpace.Rollback
            ' Remember the line number of the error
            If (ErrorLineNum = 0) Then
                ErrorLineNum = Erl
            End If
            ' Let the call deal with the error.
            Call Err.Raise(Err, M_DBCLASS + ".ReleaseIndexes:" + Err.Source, Err.Description)
            
    End Sub
    
    '*************************************************
    ' ReleaseIndexTable
    '-------------------------------------------------
    ' Purpose:  This routine will release all of the
    '           linked Ascent values to the back end
    '           database.
    ' Inputs:   The values collection
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Sub ReleaseIndexTable(TheValues As Values)
        Dim I As Integer
        Dim sField As String
        Dim nWriteAttempts As Integer
        Dim strDestinations As String
        Dim nDataType As Integer
        Dim strValues As String
        Dim strSQL As String
        
            ' Create a new record in the index table for this document.
            ' The table may be locked so retry if necessary.
            On Error GoTo RIT_TableError
            nWriteAttempts = 1
            strDestinations = ""
            strValues = ""
            
            ' Loop through each index value, set values for and create SQL statement
            On Error GoTo RIT_ColumnError
            For I = 0 To TheValues.Count - 1
                If left$(TheValues(I + 1).Destination, 3) <> "PDF" Then
                    ' Check if this is the first destination
                    If (strDestinations = "") Then
                        strDestinations = TheValues(I + 1).Destination
                        nDataType = Int(TheValues(I + 1).DataType)
                    Else
                        strDestinations = strDestinations & "," & TheValues(I + 1).Destination
                        nDataType = Int(TheValues(I + 1).DataType)
                    End If
                    
                    ' Check if this is the first value
                    If (strValues = "") Then
                        ' Check to see if this is a text value (need single quotes for SQL)
                        If (TheValues(I + 1).DataType < 2 Or TheValues(I + 1).DataType > 8) Then
                            strValues = "'" & TheValues(I + 1).Value & "'"
                        Else
                            strValues = TheValues(I + 1).Value
                        End If
                    Else
                        ' Check to see if this is a text value (need single quotes for SQL)
                        If (TheValues(I + 1).DataType < 2 Or TheValues(I + 1).DataType > 8) Then
                            strValues = strValues & "," & "'" & TheValues(I + 1).Value & "'"
                        Else
                            strValues = strValues & "," & TheValues(I + 1).Value
                        End If
                    End If
                End If
            Next I
            
            strSQL = "INSERT INTO " & strIndexTableName & " (" & strDestinations & _
                    ") VALUES (" & strValues & ")"
            
            ' Finally, update the record.
            ' The table may be locked so retry if necessary.
            On Error GoTo RIT_TableError
            nWriteAttempts = 1
    1090    DBConnection.Execute strSQL, dbSQLPassThrough
            Exit Sub
            
    '---------------
    ' Error Handler
    '---------------
    RIT_ColumnError:
            
            If Err = DAO_ERR_DataConvert Then
                ' A datatype conversion error occurred.
                ' Show the name of the Ascent index value.
                Select Case TheValues(I + 1).SourceType
                    Case KFX_REL_TEXTCONSTANT
                            sField = """" & TheValues(I + 1).SourceName & """"
                    Case KFX_REL_VARIABLE
                            sField = "{" & TheValues(I + 1).SourceName & "}"
                    Case KFX_REL_INDEXFIELD
                            sField = TheValues(I + 1).SourceName
                    Case KFX_REL_BATCHFIELD
                            sField = "{$" & TheValues(I + 1).SourceName & "}"
                    Case KFX_REL_DOCUMENTID
                            sField = TheValues(I + 1).SourceName
                End Select
                Err.Description = Err.Description & _
                                  " (" & sField & " -> " & TheValues(I + 1).Destination & ")"
            ElseIf Err = DAO_ERR_NameNotFound Then
                ' An expected column was not found in the index table.
                ' Show a more meaningful error message.
                Err.Description = LoadResString(MSG_INDEXCOLUMNMISSING)
            End If
    
            ' Always prefix the error message to indicate that an error
            ' occurred trying to set a column value in the Index Table
            Err.Description = LoadResString(MSG_INDEXCOLUMNERROR) & _
                              " (" & TheValues(I + 1).Destination & "): " & _
                              Err.Description
    
            GoTo RIT_LogAndPropError
            
    RIT_TableError:
    
            ' The table may be locked by another process.
            ' Retry the defined number of times.
            If DatabaseIsLocked() And nWriteAttempts < MAX_WRITE_ATTEMPTS Then
                nWriteAttempts = nWriteAttempts + 1
                Resume
            End If
                
            If Err = DAO_ERR_DatabaseReadOnly Then
                ' DAO error indicates that the database or object is read only.
                ' However, this error is also seen when the table is lacking a
                ' unique index, so advise of this probability.
                Err.Description = Err.Description & " " & LoadResString(MSG_READONLYERROR)
            End If
            
            ' Always prefix the error message to indicate that an error
            ' occurred trying to update a record in the Index Table
            'Err.Description = LoadResString(MSG_INDEXTABLEERROR) & _
                              " (" & grsIndexTable.Name & "): " & _
                              Err.Description
    
            GoTo RIT_LogAndPropError
    
    RIT_LogAndPropError:
            ' Remember the line number of the error
            If (ErrorLineNum = 0) Then
                ErrorLineNum = Erl
            End If
            ' Let the call deal with the error.
            Call Err.Raise(Err, M_DBCLASS + ".ReleaseIndexTable:" + Err.Source, Err.Description)
    End Sub
    
    '*************************************************
    ' ReleaseDocumentTable
    '-------------------------------------------------
    ' Purpose:  This routine releases the DocID and
    '           DocPath to the documents table.
    ' Inputs:   TheData     ReleaseData object
    '           PathName    optional release path
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Sub ReleaseDocTable(TheData As ReleaseData, ByVal PathName As String)
        Dim sPathName As String
        Dim sErrMsg As String
        Dim nWriteAttempts As Integer
        Dim strDestinations As String
        Dim strValues As String
        Dim strSQL As String
            
            On Error GoTo RDT_LogAndPropError
            
            ' If we are given the optional PathName use it.
            If (IsMissing(PathName)) Then
                sPathName = ""
            ElseIf (Len(PathName) <> 0) Then
                sPathName = PathName
            End If
            
            ' Set the pathname to the released directory
            If (sPathName = "") Then
    1110        sPathName = TheData.ImageFiles.ReleasedDirectory
            End If
            
            ' Set values for and create SQL statement
            strDestinations = TheData.CustomProperties(KEY_DOCID).Value & "," & TheData.CustomProperties(KEY_DOCPATH).Value
            strValues = TheData.UniqueDocumentID & ",'" & sPathName & "'"
            strSQL = "INSERT INTO " & strDocTableName & " (" & strDestinations & ") VALUES (" & _
                    strValues & ")"
        
            ' Update the table.
            ' The table may be locked so retry if necessary.
            On Error GoTo RDT_TableError
            nWriteAttempts = 1
    1120    DBConnection.Execute strSQL, dbSQLPassThrough
            
            Exit Sub
            
    '---------------
    ' Error Handler
    '---------------
    RDT_DocIDError:
    
            If Err = DAO_ERR_NameNotFound Then
                ' The Document ID column is missing in the table
                Err.Description = LoadResString(MSG_DOCCOLUMNMISSING)
            End If
            
            ' Always prefix the error message to indicate that an error
            ' occurred trying to set a column value in the Document Table
            Err.Description = LoadResString(MSG_DOCCOLUMNERROR) & _
                              " (" & TheData.CustomProperties(KEY_DOCID).Value & "): " & _
                              Err.Description
            
            GoTo RDT_LogAndPropError
            
    RDT_DocPathError:
    
            If Err = DAO_ERR_NameNotFound Then
                ' The Document Path column is missing in the table
                Err.Description = LoadResString(MSG_DOCCOLUMNMISSING)
            End If
                    
            ' Always prefix the error message to indicate that an error
            ' occurred trying to set a column value in the Document Table
            Err.Description = LoadResString(MSG_DOCCOLUMNERROR) & _
                              " (" & TheData.CustomProperties(KEY_DOCPATH).Value & "): " & _
                              Err.Description
            
            GoTo RDT_LogAndPropError
    
    RDT_TableError:
    
            ' The table may be locked by another process.
            ' Retry the defined number of times.
            If DatabaseIsLocked() And nWriteAttempts < MAX_WRITE_ATTEMPTS Then
                nWriteAttempts = nWriteAttempts + 1
                Resume
            End If
            
            If Err = DAO_ERR_KeyDuplicate Then
                ' A duplicate index or primary key exists.  The DAO message is
                ' long and not very descriptive.  Change the message to indicate
                ' a record already exists for this document.
                Err.Description = LoadResString(MSG_DOCALREADYRELEASED) _
                                    & ": " & Format$(TheData.UniqueDocumentID)
            ElseIf Err = DAO_ERR_DatabaseReadOnly Then
                ' DAO error indicates that the database or object is read only.
                ' However, this error is also seen when the table is lacking a
                ' unique index, so advise of this probability.
                Err.Description = Err.Description & " " & LoadResString(MSG_READONLYERROR)
            End If
            
            
            ' Always prefix the error message to indicate that an error
            ' occurred trying to update a record in the Document Table
            'Err.Description = LoadResString(MSG_DOCTABLEERROR) & _
                              " (" & grsDocTable.Name & "): " & _
                              Err.Description
            
            GoTo RDT_LogAndPropError
    
    RDT_LogAndPropError:
            ' Remember the line number of the error
            If (ErrorLineNum = 0) Then
                ErrorLineNum = Erl
            End If
            
            ' Let the caller deal with the error.
            Call Err.Raise(Err, M_DBCLASS + ".ReleaseDocTable:" + Err.Source, Err.Description)
            
    End Sub
    
    '*************************************************
    ' CleanUpDBConnection
    '-------------------------------------------------
    ' Purpose:  This routine will close down all the
    '           connections to the database.  This
    '           should be done as the script exits.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Sub CleanUpDBConnection()
    
            On Error Resume Next
            
            ' Close the recordsets
    '1150    grsIndexTable.Close
    '1160    grsDocTable.Close
            
            ' Close the database
            If Connected Then
    1180        DBConnection.Close
                Set DBConnection = Nothing
    1190        oWorkSpace.Close
                Set oWorkSpace = Nothing
                Set oDbEngine = Nothing
                CurrentDTable = ""
                CurrentITable = ""
                Connected = False
            End If
    End Sub
    
    '*************************************************
    ' Class_Terminate
    '-------------------------------------------------
    ' Purpose:  Make sure we have disconnected from
    '           the database and cleaned up in case
    '           we exit abnormally.
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  None
    ' Notes:    None
    '*************************************************
    Private Sub Class_Terminate()
            On Error Resume Next
    1200    Call CleanUpDBConnection
    End Sub
    
    '*************************************************
    ' DatabaseIsLocked
    '-------------------------------------------------
    ' Purpose:  Checks the last error to determine
    '           if it was due to a locked database
    ' Inputs:   None
    ' Outputs:  None
    ' Returns:  True if the Err code represents a
    '           database access conflict;
    '           otherwise, False
    ' Notes:    DO NOT add an error handler here
    '*************************************************
    Private Function DatabaseIsLocked() As Boolean
    
        ' *** NOTE ***
        ' Do not add an error handler here or the
        ' previous Err information will be lost
        ' *** NOTE ***
        
            Select Case Err
                
                Case DAO_ERR_ReadConflictM, _
                     DAO_ERR_ReadConflict, _
                     DAO_ERR_CommitConflictM, _
                     DAO_ERR_CommitConflict, _
                     DAO_ERR_WriteConflictM, _
                     DAO_ERR_WriteConflict, _
                     DAO_ERR_RecordLocked, _
                     DAO_ERR_FileLockingUnavailable, _
                     DAO_ERR_DatabaseLocked, _
                     DAO_ERR_TableInUse, _
                     DAO_ERR_FileShareViolation, _
                     DAO_ERR_FileLockViolation
                        DatabaseIsLocked = True
                    
                Case Else
                        DatabaseIsLocked = False
            
            End Select
            
    End Function
    thanks for all your help.


    [Edited by billyboy on 10-08-2000 at 01:57 AM]

  5. #5
    Member
    Join Date
    Jun 2000
    Posts
    32
    hello

    I need to do a similar thing (release to SQL) but I am comple new to Ascent capture. How do i go about indexing a document and releasing it to a SQL DB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width