Re: Writing an exception log an opening it with Notepad.exe

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Look at Process.Start

RSH wrote:
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



.



Relevant Pages

  • Writing an exception log an opening it with Notepad.exe
    ... values from that DataTable and inserting them into a SQL database. ... application works fine but now I want to add an exception log to the ... running string that adds errors to the string if they happen. ... Would you like to view the Error Log now?", "Confirm", ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Detailed ASP.Net info not displaying in browser
    ... HTTP 500 page when an exception is thrown from the web service. ... at VOSE.Data.DataRequest.dr_DB2Process.DeleteCommRows(String company, String ... objQueue, tOrderManagementIndicator omindicator, Int32 intTriggerId) in ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.xml)
  • RE: Detailed ASP.Net info not displaying in browser
    ... HTTP 500 page when an exception is thrown from the web service. ... at VOSE.Data.DataRequest.dr_DB2Process.DeleteCommRows(String company, String ... objQueue, tOrderManagementIndicator omindicator, Int32 intTriggerId) in ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.xml)
  • Re: App_data - ASPNETDB.MDF
    ... is only because I want my site work, without exception. ... Server Error in '/' Application. ... serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Could not load file or assembly...
    ... The problem shows when EL exception handling ... context, ExceptionHandlerData objectConfiguration, IConfigurationSource ... configurationSource, ConfigurationReflectionCache reflectionCache) ... context, String name, IConfigurationSource configurationSource, ...
    (microsoft.public.dotnet.framework)