MDB,code,pastes,into,Module,Create,exists,rec
Quick Search for:  in language:    
MDB,code,pastes,into,Module,Create,exists,rec
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
RentACoder Stats

 Code:  lines
 Jobs: 0 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for RentACoder.
Wrapping Scrolling Text
By Paranoid_Androi d on 7/2


Create A Dummy File
By AML on 7/2


Click here to see a screenshot of this code!Captionbar manipulation!
By Peter Hebels on 7/2

(Screen Shot)

A Game Of War
By Co0nest on 7/2


Click here to see a screenshot of this code!KeyGen Example
By Bengie|NET on 7/2

(Screen Shot)

Click here to see a screenshot of this code!OpenBrowser v1.9
By Orlando Jerez on 7/2

(Screen Shot)

SendMessageBySt ring() Example
By Jaime Muscatelli on 7/2


Click here to see a screenshot of this code!FirstSunday
By Jan Paul Penning on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Ikonz v1.0
By Gaurav Creations on 7/2

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Error Handler Document

Print
Email
 
VB icon
Submitted on: 6/3/1999
By: WalkerBro  
Level: Not Given
User Rating: By 103 Users
Compatibility:

Users have accessed this code 7505 times.
 
 
     This code pastes into a Module that Create (if not exists) a MDB to record the errors that occur in your application.
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    //**************************************
    //     
    //Windows API/Global Declarations for :E
    //     rror Handler Document
    //**************************************
    //     
    Public Type SECURITY_ATTRIBUTES
    nLength As Long
    lpSecurityDescriptor As Long
    bInheritHandle As Long
    End Type
    Public Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Error Handler Document
    // Description:This code pastes into a M
    //     odule that Create (if not exists) a MDB 
    //     to record the errors that occur in your 
    //     application.
    // By: WalkerBro
    //
    // Inputs:Needs (DatabaseName, Date, Err
    //     .Number, Err.Description, PrivateNotes, 
    //     Optional(User))
    Load in "References" the "Microsoft DAO 3.51 Object Library"
    //
    // Returns:True or False if it was succe
    //     sful.
    //
    // Assumes:Basic Error handling informat
    //     ion.
    //
    // Side Effects:No known side effects.
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.1950/lngWId.-10/qx/vb/scripts/ShowCo
    //     de.htm    //for details.    //**************************************
    //     
    
    '* Created by Walker Brother (tm)
    '* web page : http://www.walkerbro.8m.com
    '* e-mail: info@walkerbro.8m.com
    '* This Module Logs the Errors your application may incounter into a MDB, if the MDB
    '* does not exist the it Creates it.
    '* It Creates a passworded MDB to stop other accessing your errors, you then can make
    '* a frontend to read your errors.
    '* Table Name : ErrList
    '* Field Name : ErrDate, ErrDes, ErrNum, ErrNotes, ErrUser '* 'Usage 
    '* Error_Handler:
    '* Select Case Error_Handler_Doc("Name.mdb", Now, 123, "Description", "Notes")
    '* Case "True" 
    '* Case "False"
    '* End Select
    '* Load in "References" the "Microsoft DAO 3.51 Object Library"
    Dim NewDB As Database
    Dim ExistDB As Database
    Dim ExistRS As Recordset
    Public Function Error_Handler_Doc(ByVal ErrMDB As String, ErrDate As Date, ErrNum As Long, ErrDes As String, ErrNote As String, Optional ErrUser As String) As Boolean
    Select Case Error_Handler_MDB(ErrMDB)
    Case "False"
    If Error_Handler_Create(ErrMDB, "!@#$") = False Then
    Error_Handler_Doc = False
    Exit Function
    End If
    End Select
    Set ExistDB = OpenDatabase("C:\Program Files\Common Files\Walker Brothers\ErrorHandler\" & ErrMDB, False, False, ";pwd=!@#$")
    Set ExistRS = ExistDB.OpenRecordset("ErrList", dbOpenDynaset)
    ExistRS.AddNew
    ExistRS.Fields!ErrNum = ErrNum & ""
    ExistRS.Fields!ErrDate = ErrDate & ""
    ExistRS.Fields!ErrDes = ErrDes & ""
    ExistRS.Fields!ErrNote = ErrNote & ""
    ExistRS.Fields!ErrUser = ErrUser & ""
    ExistRS.Update
    ExistRS.Close
    ExistDB.Close
    Set ExistRS = Nothing
    Set ExistDB = Nothing
    Error_Handler_Doc = True
    End Function
    Public Function Error_Handler_MDB(ByVal ErrMDB As String) As Boolean
    On Error Resume Next
    Open "C:\Program Files\Common Files\Walker Brothers\ErrorHandler\" & ErrMDB For Input As #1
    If Err Then
    Error_Handler_MDB = False
    Exit Function
    End If
    Close #1
    Error_Handler_MDB = True
    End Function
    Public Function Error_Handler_Create(ByVal ErrMDB As String, ByVal ErrMDBPassword As String) As Boolean
    Error_Handler_Create = False
    If CreateNewDirectory("C:\Program Files\Common Files\Walker Brothers\ErrorHandler") = False Then
    Exit Function
    End If
    On Error GoTo Err_Handler
    If ErrMDBPassword <> "" Then
    Set NewDB = Workspaces(0).CreateDatabase("C:\Program Files\Common Files\Walker Brothers\ErrorHandler\" & ErrMDB, dbLangGeneral & ";pwd=" & ErrMDBPassword)
    Else
    Set NewDB = Workspaces(0).CreateDatabase("C:\Program Files\Common Files\Walker Brothers\ErrorHandler\" & ErrMDB, dbLangGeneral)
    End If
    'Now call the functions for each table
    Dim b As Boolean
    b = Error_Handler_Err_List
    If b = False Then
    Error_Handler_Create = False
    NewDB.Close
    Set NewDB = Nothing
    Exit Function
    End If
    Error_Handler_Create = True
    SetAttr "C:\Program Files\Common Files\Walker Brothers\ErrorHandler\" & ErrMDB, vbHidden
    Exit Function
    Err_Handler:
    If Err.Number <> 0 Then
    Error_Handler_Create = False
    NewDB.Close
    Set NewDB = Nothing
    Exit Function
    End If
    End Function
    Public Function Error_Handler_Err_List() As Boolean
    Dim TempTDef As TableDef
    Dim TempField As Field
    Dim TempIdx As Index
    Error_Handler_Err_List = False
    On Error GoTo Err_Handler
    Set TempTDef = NewDB.CreateTableDef("ErrList")
    Set TempField = TempTDef.CreateField("ErrDate", 8)
    TempField.Attributes = 1
    TempField.Required = False
    TempField.OrdinalPosition = 0
    TempTDef.Fields.Append TempField
    TempTDef.Fields.Refresh
    Set TempField = TempTDef.CreateField("ErrNum", 4)
    TempField.Attributes = 1
    TempField.Required = False
    TempField.OrdinalPosition = 1
    TempTDef.Fields.Append TempField
    TempTDef.Fields.Refresh
    Set TempField = TempTDef.CreateField("ErrDes", 12)
    TempField.Attributes = 2
    TempField.Required = False
    TempField.OrdinalPosition = 2
    TempField.AllowZeroLength = False
    TempTDef.Fields.Append TempField
    TempTDef.Fields.Refresh
    Set TempField = TempTDef.CreateField("ErrNote", 12)
    TempField.Attributes = 2
    TempField.Required = False
    TempField.OrdinalPosition = 3
    TempField.AllowZeroLength = False
    TempTDef.Fields.Append TempField
    TempTDef.Fields.Refresh
    Set TempField = TempTDef.CreateField("ErrUser", 10)
    TempField.Attributes = 2
    TempField.Required = False
    TempField.OrdinalPosition = 4
    TempField.Size = 50
    TempField.AllowZeroLength = True
    TempTDef.Fields.Append TempField
    TempTDef.Fields.Refresh
    NewDB.TableDefs.Append TempTDef
    NewDB.TableDefs.Refresh
    'Done, Close the objects
    Set TempTDef = Nothing
    Set TempField = Nothing
    Set TempIdx = Nothing
    Error_Handler_Err_List = True
    Exit Function
    Err_Handler:
    If Err.Number <> 0 Then
    Set TempTDef = Nothing
    Set TempField = Nothing
    Set TempIdx = Nothing
    Error_Handler_Err_List = False
    Exit Function
    End If
    End Function
    Public Function CreateNewDirectory(ByVal NewDirectory As String) As Boolean
    Dim sDirTest As String
    Dim SecAttrib As SECURITY_ATTRIBUTES
    Dim bSuccess As Boolean
    Dim sPath As String
    Dim iCounter As Integer
    Dim sTempDir As String
    Dim iFlag As Integer
    On Error GoTo ErrorCreate
    iFlag = 0
    sPath = NewDirectory
    If Right(sPath, Len(sPath)) <> "\" Then
    sPath = sPath & "\"
    End If
    iCounter = 1
    Do Until InStr(iCounter, sPath, "\") = 0
    iCounter = InStr(iCounter, sPath, "\")
    sTempDir = Left(sPath, iCounter)
    sDirTest = Dir(sTempDir)
    iCounter = iCounter + 1
    'create directory
    SecAttrib.lpSecurityDescriptor = &O0;
    SecAttrib.bInheritHandle = False
    SecAttrib.nLength = Len(SecAttrib)
    bSuccess = CreateDirectory(sTempDir, SecAttrib)
    Loop
    CreateNewDirectory = True
    Exit Function
    ErrorCreate:
    CreateNewDirectory = False
    Resume 0
    End Function
    ''Usage
    'Select Case Error_Handler_Doc("Name.mdb", Now, 123, "Description", "Notes")
    'Case "True"
    'Case "False"
    'End Select


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
6/3/1999 12:47:00 PM:casper
This is a cool code. Now in my apps, i 
can make it send the error file to me 
so i can fix it
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/20/1999 4:40:00 AM:Jim Wilson
Very useful code. Just a couple of 
points
1. You don't need to refresh 
the TableDefs collection everytime you 
append a field.
2. Rather than 
saying 
ExistRS.Fields!ErrNum 
you can just 
say
ExistRS!ErrNum
Sorry don't 
mean to be picky, overall its nice 
code
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/20/1999 3:41:00 PM:i3ki3
It says user defined tuype not defined 
for database
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/22/1999 11:31:00 AM:ValkRider
User:  i3ki3, above, 
forgot to add 
DAO 3.5 or greater to the Project's 
References section before compiling or 
running the code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | RentACoder Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.