Changes between Version 4 and Version 5 of Docs/Prog/Manual/ApplicationLibraries/lib825mssql


Ignore:
Timestamp:
10/26/26 07:09:49 (5 days ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/ApplicationLibraries/lib825mssql

    v4 v5  
    77
    88//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.
     9
     10An example to have an app support SQLite, MySQL, or SQL Server:
     11{{{#!c++
     12CAppDatabaseCfg appDBcfg;
     13string path = appDataPath + CFGFILE_DB;
     14appDBcfg.SetArchiveFilepath(path);
     15appDBcfg.ReadConfig();
     16
     17if(appDBcfg.GetDBType() == CAppDatabaseCfg::appDataMySQL) {
     18   appDB = new CDBMySQL(appDBcfg.GetServer(), appDBcfg.GetUser(), appDBcfg.GetPassword(), appDBcfg.GetDatabase());
     19} else if(appDBcfg.GetDBType() == CAppDatabaseCfg::appDataMSSQL) {
     20   appDB = new CDBMSSQL(appDBcfg.GetServer(), appDBcfg.GetUser(), appDBcfg.GetPassword(), appDBcfg.GetDatabase());
     21} else {
     22   appDB = new CDBSQLite("/mnt/nand/apps/<appdir>/myapp.db3");
     23}
     24
     25if(appDB->OpenDatabase() == false) {
     26   DEBUG_MSG("Error [%s]\n", appDB->GetErrorMsg().c_str());
     27   DrawErrorBox("Cannot open database", 4);
     28}
     29}}}
     30CAppDatabaseCfg 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.
     31
     32This instantiates a CDBMySQL object for MySQL, or 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.
     33