Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Writing error to a browser

Writing error to a browser

Scheduled Pinned Locked Moved C#
databasehelpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kibromg
    wrote on last edited by
    #1

    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));

    0 L G 3 Replies Last reply
    0
    • K kibromg

      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));

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      This isn't my field of knowledge, but I would think that you would do Response.Write(ex.Message). As it is now, that line of code won't even compile

      Between the idea And the reality Between the motion And the act Falls the Shadow

      1 Reply Last reply
      0
      • K kibromg

        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));

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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![^]

        1 Reply Last reply
        0
        • K kibromg

          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));

          G Offline
          G Offline
          Gary Stafford
          wrote on last edited by
          #4

          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 to Console.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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups