Writing error to a browser
-
Hi all, I am trying to write a database connection error to a Browser using Response.write("error message") command. try { cnx.Open(); cmd.ExecuteNonQuery(); // sResult = int.Parse(par.Value.ToString());// 1 if successful insert } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { cnx.Close(); } I would like to write the error message to a browser if connection is not possible. can i do this? resonse.write (Console.WriteLine(ex.Message));
-
Hi all, I am trying to write a database connection error to a Browser using Response.write("error message") command. try { cnx.Open(); cmd.ExecuteNonQuery(); // sResult = int.Parse(par.Value.ToString());// 1 if successful insert } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { cnx.Close(); } I would like to write the error message to a browser if connection is not possible. can i do this? resonse.write (Console.WriteLine(ex.Message));
-
Hi all, I am trying to write a database connection error to a Browser using Response.write("error message") command. try { cnx.Open(); cmd.ExecuteNonQuery(); // sResult = int.Parse(par.Value.ToString());// 1 if successful insert } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { cnx.Close(); } I would like to write the error message to a browser if connection is not possible. can i do this? resonse.write (Console.WriteLine(ex.Message));
So your application is a console application? Why are you unable to write to the Console, the only thing I fear is that you are creating a windows forms application and you are still trying to write to the console.
Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]
-
Hi all, I am trying to write a database connection error to a Browser using Response.write("error message") command. try { cnx.Open(); cmd.ExecuteNonQuery(); // sResult = int.Parse(par.Value.ToString());// 1 if successful insert } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { cnx.Close(); } I would like to write the error message to a browser if connection is not possible. can i do this? resonse.write (Console.WriteLine(ex.Message));
Yes, the first answer (Computafreak's) is correct,
Response.Write(ex.Message);
if your writing an ASP.NET Web Application. But, looking at your code, I suspect you are writing a Windows Application due to your reference toConsole.WriteLine()
. This is a stretch, you want to send a Windows Application generated error message to a web browser window? Who's browser - yours, or a user of the application? At what URL? I think you may want to CLARIFY your question with some more details on the type of application you are writing.Regards, Gary