| Version 6 (modified by , 5 days ago) ( diff ) |
|---|
Library for Microsft SQL Server database support (lib825mssql)
Comming Soon
lib825mssql provides a CDBMSSQL class inherited from class CDB in lib825db to facilitate apps also being able to use common code for Microsoft SQL databases.
Note this library provides client connectivity. The database will have to be hosted on a SQL Server instance running on a Windows PC or server.
An example to have an app support SQLite, MySQL, or SQL Server:
CAppDatabaseCfg appDBcfg; string path = appDataPath + CFGFILE_DB; appDBcfg.SetArchiveFilepath(path); appDBcfg.ReadConfig(); if(appDBcfg.GetDBType() == CAppDatabaseCfg::appDataMySQL) { appDB = new CDBMySQL(appDBcfg.GetServer(), appDBcfg.GetUser(), appDBcfg.GetPassword(), appDBcfg.GetDatabase()); } else if(appDBcfg.GetDBType() == CAppDatabaseCfg::appDataMSSQL) { appDB = new CDBMSSQL(appDBcfg.GetServer(), appDBcfg.GetUser(), appDBcfg.GetPassword(), appDBcfg.GetDatabase()); } else { appDB = new CDBSQLite("/mnt/nand/apps/<appdir>/myapp.db3"); } if(appDB->OpenDatabase() == false) { DEBUG_MSG("Error [%s]\n", appDB->GetErrorMsg().c_str()); DrawErrorBox("Cannot open database", 4); }
CAppDatabaseCfg is not part of lib825db. This code is in the ID Storage app to provide a user interface and load/save database configuration. The files appdatabase.cpp and appdatabase.h may be copied from ID Storage for your own apps and customized if desired.
This instantiates a CDBMySQL object for MySQL, a CDBMSSQL object for SQL Server, or a CDBSQLite object for SQLite based on the configuration. The created object is assigned to the pointer CDB* appDB.
Attachments (2)
- appdatabase.cpp (8.5 KB ) - added by 3 days ago.
- appdatabase.h (1.9 KB ) - added by 3 days ago.
Download all attachments as: .zip
![(please configure the [header_logo] section in trac.ini)](/chrome/site/cardinal.gif)