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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. exception handling

exception handling

Scheduled Pinned Locked Moved C / C++ / MFC
databasequestion
3 Posts 2 Posters 1 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.
  • P Offline
    P Offline
    prithaa
    wrote on last edited by
    #1

    Hello, I am using CDatabase 's pen function t pen a database .Now I want to flag a message if the database desn't exist or it is not opening. CDatabase::Open() does not return true r false so tried using try catch throw but the control does not go to catch part of the above block What do I do ? I did the following try { if (!CurrentDatabase.IsOpen()) CurrentDatabase.Open(_T(DatabaseName),FALSE,FALSE,_T("ODBC;")); } catch (CFileException* e) { AfxMessageBox("Check your Database"); throw; } Regards Prithaa

    C 1 Reply Last reply
    0
    • P prithaa

      Hello, I am using CDatabase 's pen function t pen a database .Now I want to flag a message if the database desn't exist or it is not opening. CDatabase::Open() does not return true r false so tried using try catch throw but the control does not go to catch part of the above block What do I do ? I did the following try { if (!CurrentDatabase.IsOpen()) CurrentDatabase.Open(_T(DatabaseName),FALSE,FALSE,_T("ODBC;")); } catch (CFileException* e) { AfxMessageBox("Check your Database"); throw; } Regards Prithaa

      C Offline
      C Offline
      C Mahesh
      wrote on last edited by
      #2

      As far as I am aware, CDatabase class will throw a Database exception (CDBException) and not CFileException.

      P 1 Reply Last reply
      0
      • C C Mahesh

        As far as I am aware, CDatabase class will throw a Database exception (CDBException) and not CFileException.

        P Offline
        P Offline
        prithaa
        wrote on last edited by
        #3

        Hello, Thanks ,It worked. I should have checked that. Prithaa

        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