Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2005

Tip: Looking for answers? Try searching our database.

Writing an exception log an opening it with Notepad.exe

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RSH - 28 Dec 2005 20:50 GMT
Hi all,

I have a situation where I am looping through a DataTable and extracting
values from that DataTable and inserting them into a SQL database.  The
application works fine but now I want to add an exception log to the
application. So, I added an Exception handling routine that basically has a
running string that adds errors to the string if they happen.  I have three
questions:

1.  If a SQL exception happens I would like it to write it to the
ErrorString and then continue to the next record (kind of like the old
Resume Next in VB).

2.  When the application finishes running and there is an error in the error
string I would like to write the error to a text file in the application
path and then open the file using NotePad.exe.

3. How do I find the Application Path?

Exception Handling Code Excerpt:

catch (Exception e)

{

strError += "[DATA TRANSFER ERROR][Error: " + e.Message + "][Record Number:
" + iGlobalRecordProgress + "]";

// Resume Next

}

At the end of the application I detect if an error has occured:

if (strError.Length > 1)

{

TextWriter tw = new StreamWriter("DataImportErrorLog-" + DateTime.Now +
".txt");

tw.WriteLine(strError);

tw.Close();

DialogResult result = MessageBox.Show("Errors occurred during the data
transfer. Would you like to view the Error Log now?", "Confirm",
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

if (result == DialogResult.OK)

{

// Open Error Log file with Notepad.exe

}

How do I go about that?

Thanks!
Ron
Benny Raymond - 28 Dec 2005 21:54 GMT
Look at Process.Start

> Hi all,
>
[quoted text clipped - 57 lines]
> Thanks!
> Ron
mwolf - 28 Dec 2005 22:15 GMT
path: AppDomain.CurrentDomain.BaseDirectory

for execution see System.Diagnostics.Process

hope it helps
mwolf - 28 Dec 2005 22:23 GMT
also see

http://www.codeproject.com/script/comments/forums.asp?forumid=1649&mpp=50&tid=13
18436&select=1318622#xx1318622xx


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.