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. Opening a CDatabase object

Opening a CDatabase object

Scheduled Pinned Locked Moved C / C++ / MFC
database
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.
  • B Offline
    B Offline
    Baatezu
    wrote on last edited by
    #1

    I am using CDatabase and I want to be able to open the database without the user having to select anything. (Users like to break stuff, I want no breaking) I can get it so I just have to select the database with this code: dbSNDB.OpenEx("DSN=MS Access Database,", 0); And I am wondering if there is anything I can do to make it so it open's the database automtically. I am still having to select the database from the options it pops up. Thanks The wisest of the wise may err. - Aeschylus

    F 1 Reply Last reply
    0
    • B Baatezu

      I am using CDatabase and I want to be able to open the database without the user having to select anything. (Users like to break stuff, I want no breaking) I can get it so I just have to select the database with this code: dbSNDB.OpenEx("DSN=MS Access Database,", 0); And I am wondering if there is anything I can do to make it so it open's the database automtically. I am still having to select the database from the options it pops up. Thanks The wisest of the wise may err. - Aeschylus

      F Offline
      F Offline
      Florin Ochiana
      wrote on last edited by
      #2

      If there's only one database you can do this: bd.Open(_T("Your-DSN"),FALSE, FALSE, _T("ODBC;UID=yourUserName;PWD=yourPass;Database=yourDb")); if (bd.IsOpen()) // it's ok else { // error } If you want the user to select a database you can let him choose from a list (but not the one opened by ODBC). Then you try to open the connection with the database selected by the user with the code above. If there's any error you display an error message. ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.

      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