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 / C++ / MFC
  4. Can do that???

Can do that???

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++helpquestion
2 Posts 2 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.
  • D Offline
    D Offline
    don7cry
    wrote on last edited by
    #1

    when I use code in C++ or C# to excute SQLCommand, and it throw SQLExcetion. Can I write another application to catch it. somebody can help me or tell me an idea. thanks Nho'c Ti`

    A 1 Reply Last reply
    0
    • D don7cry

      when I use code in C++ or C# to excute SQLCommand, and it throw SQLExcetion. Can I write another application to catch it. somebody can help me or tell me an idea. thanks Nho'c Ti`

      A Offline
      A Offline
      Antti Keskinen
      wrote on last edited by
      #2

      Exceptions are errorenous program states from which it is still possible to close the program gracefully without losing data or crashing the system. In C++, you can handle raised exceptions by using a try - catch block. You write the code you wish to execute in the try block, and then write either a conditional (specific exception) catch block or a generic one, if available. Here is an example of handling an SQL-query exception:

      try
      {
      CRecordset myRecordset(&db);
      myRecordset.Open(...);
      }
      catch ( CDBException* e )
      {
      // If an exception is raised
      AfxMessageBox( e->m_strError, MB_OK );

      e->Delete();
      

      }

      For more hands-on information and how to write your own routines that raise exceptions, see MSDN Library for Exception handling topics (C++)[^]. Hope this helps, Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

      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