Changes between Version 7 and Version 8 of Docs/Prog/Manual/ApplicationLibraries/lib825mssql


Ignore:
Timestamp:
10/27/26 13:19:26 (4 days ago)
Author:
Don Wilson
Comment:

--

Legend:

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

    v7 v8  
    3232This 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.
    3333
     34{{{#!c++
     35        if(dynamic_cast<CDBMSSQL*>(appDB)) {
     36                sql = "IF OBJECT_ID('dbo.axleTrans', 'U') IS NULL BEGIN CREATE TABLE axleTrans (";
     37        } else {
     38                sql = "CREATE TABLE IF NOT EXISTS axleTrans (";
     39        }
     40
     41                        if(dynamic_cast<CDBMySQL*>(appDB)) {
     42                                sql +=  "id INTEGER PRIMARY KEY AUTO_INCREMENT,";
     43                        } else if(dynamic_cast<CDBMSSQL*>(appDB)) {
     44                                sql += "id INTEGER IDENTITY(1,1) PRIMARY KEY,";
     45                        } else {
     46                                sql += "id INTEGER PRIMARY KEY,"; // SQLite: INTEGER PRIMARY KEY aliases ROWID and auto-increments
     47                        }
     48                        sql +=
     49                                "cost TEXT," // amount of this transaction
     50                                "pmt_type TEXT," // CASH if cash, else CREDIT if Account customer
     51                                "badge TEXT," // Badge ID (if CREDIT)
     52                                "customer TEXT,"; // The customer name (if CREDIT)
     53
     54                        for(n = 0; n < MAX_DB_AXLES; n++) {
     55                                sql += "axle" + to_string(n + 1) + " REAL,";
     56                        }
     57
     58                        sql += "grossT REAL" // Total wt (sum of wts)
     59                                ",datetm DATETIME"
     60                                ");";
     61        if(dynamic_cast<CDBMSSQL*>(appDB)) {
     62                sql += " END";
     63        }
     64
     65                if(appDB->Execute(sql) == false) {
     66                        DrawErrorBox("Error creating transaction table", 2);
     67                }
     68
     69}}}