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. Database & SysAdmin
  3. Database
  4. How will I know that DSN is not pointing to any database?

How will I know that DSN is not pointing to any database?

Scheduled Pinned Locked Moved Database
c++databasequestioncsharpdiscussion
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.
  • P Offline
    P Offline
    PrashantJ
    wrote on last edited by
    #1

    Hi, I have the following C++ code, using MS-studio.Net (MFC). CDatabase aDatabase; TCHAR buffer[400]; SQLRETURN rc = SQLGetInfo(aDatabase.m_hdbc, SQL_DATABASE_NAME,(SQLPOINTER buffer, sizeof(buffer), &size); With this code at present, the value returned in buffer if "master" if the DSN is not pointing to any database. I think master is the default database. I actually want to know if the DSN is pointing to a correct(existing) database or not. I wanted to display a message if the DSN is not pointing to any database or if its pointing to a database that no more exists. How can I achieve this? Anybody any thoughts? Thanks, Joe

    M 1 Reply Last reply
    0
    • P PrashantJ

      Hi, I have the following C++ code, using MS-studio.Net (MFC). CDatabase aDatabase; TCHAR buffer[400]; SQLRETURN rc = SQLGetInfo(aDatabase.m_hdbc, SQL_DATABASE_NAME,(SQLPOINTER buffer, sizeof(buffer), &size); With this code at present, the value returned in buffer if "master" if the DSN is not pointing to any database. I think master is the default database. I actually want to know if the DSN is pointing to a correct(existing) database or not. I wanted to display a message if the DSN is not pointing to any database or if its pointing to a database that no more exists. How can I achieve this? Anybody any thoughts? Thanks, Joe

      M Offline
      M Offline
      Michael Potter
      wrote on last edited by
      #2

      Ask for the schema: SELECT TABLE_CATALOG FROM INFORMATION_SCHEMA.TABLES GROUP BY TABLE_CATALOG Look up INFORMATION_SCHEMA in BOL if you need to verify more than just the catalog (database) name.

      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