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