void myClass::CreateTable() {
    try {
        // Name's data
        wapstr = L"CREATE TABLE ";
        wapstr += table_name;
        wapstr += L"(";
        wapstr += L"id INT PRIMARY KEY NOT NULL, ";
        wapstr += L"title_name TEXT, ";
        wapstr += L"first_name TEXT, ";
        wapstr += L"middle_name TEXT, ";
        wapstr += L"last_name TEXT, ";
        // Address data
        wapstr += L"unit_number TEXT, ";
        wapstr += L"street_name TEXT, ";
        wapstr += L"city TEXT, ";
        wapstr += L"province TEXT, ";
        wapstr += L"postal_code TEXT, ";
        wapstr += L"country TEXT, ";
        // Phone1 data
        wapstr += L"country_code1 TEXT, ";
        wapstr += L"area_code1 TEXT, ";
        wapstr += L"region_code1 TEXT, ";
        wapstr += L"number1 TEXT, ";
        // Phone2 data
        wapstr += L"country_code2 TEXT, ";
        wapstr += L"area_code2 TEXT, ";
        wapstr += L"region_code2 TEXT, ";
        wapstr += L"number2 TEXT, ";
        // Phone3 data
        wapstr += L"country_code3 TEXT, ";
        wapstr += L"area_code3 TEXT, ";
        wapstr += L"region_code3 TEXT, ";
        wapstr += L"number3 TEXT, ";
        // Phone4 data
        wapstr += L"country_code4 TEXT, ";
        wapstr += L"area_code4 TEXT, ";
        wapstr += L"region_code4 TEXT, ";
        wapstr += L"number4 TEXT, ";
        // Email1 data
        wapstr += L"email1 TEXT, ";
        // Email2 data
        wapstr += L"email2 TEXT";
        wapstr += L");";
/*
Test shows:
CREATE TABLE Name(id INT PRIMARY KEY NOT NULL, title_name TEXT, first_name TEXT, middle_name TEXT, last_name TEXT, unit_number TEXT, street_name TEXT, city TEXT, province TEXT, postal_code TEXT, country TEXT, country_code1 TEXT, area_code1 TEXT, region_code1 TEXT, number1 TEXT, country_code2 TEXT, area_code2 TEXT, region_code2 TEXT, number2 TEXT, country_code3 TEXT, area_code3 TEXT, region_code3 TEXT, number3 TEXT, country_code4 TEXT, area_code4 TEXT, region_code4 TEXT, number4 TEXT, email1 TEXT, email2 TEXT);
*/

        db->createTable(wapstr);

    } catch (std::shared_ptr<jme::WinException>& e) {
        throw e;
    }
}

void jme::SQLite3_RDB::createTable(const std::wstring& stm) {
    // 1) Assign function value to class value
    this->sql_statement_request = stm;
/*
Test shows that sql_statement_request is :
CREATE TABLE Name(id INT PRIMARY KEY NOT NULL, title_name TEXT, first_name TEXT, middle_name TEXT, last_name TEXT, unit_number TEXT, street_name TEXT, city TEXT, province TEXT, postal_code TEXT, country TEXT, country_code1 TEXT, area_code1 TEXT, region_code1 TEXT, number1 TEXT, country_code2 TEXT, area_code2 TEXT, region_code2 TEXT, number2 TEXT, country_code3 TEXT, area_code3 TEXT, region_code3 TEXT, number3 TEXT, country_code4 TEXT, area_code4 TEXT, region_code4 TEXT, number4 TEXT, email1 TEXT, email2 TEXT);
*/
    // ******* THE ERROR IS HERE ****************
    this->rc = ::sqlite3_prepare_v2(db, convert->toString(sql_statement_request).c_str(), -1, &binary_sql_statement, NULL);
    if (this->rc != SQLITE_OK) {
        this->apstr = "Error message from SQLite3 ";
        this->apstr += ::sqlite3_errmsg(db);
        this->apstr += "\nError code: ";
        this->apstr += jme::core::to_string(this->rc);
        this->wapex->setException(this->apstr, JMEFILE, JMEMETHOD, JMELINE);

        this->finalize();

        throw this->wapex;
    }
    try {
        this->runStep(this->binary_sql_statement);
    } catch (std::shared_ptr<jme::WinException>& we) {
        throw we;
    }

    // Call finalize to terminate the transaction - The constructor closes the db connection.
    this->finalize();
}

The code shows what I have done to create a table, but ::sqlite3_prepare_v2 tells me:
---------------------------
Exception
---------------------------
Error message from SQLite3 - bad parameter or other API misuse
Error code: 21

The source code for SQLite3_RDB is here, should you'd like to see it.
http://arbolone.ca/Testings/sqlite3_rdb01.html
http://arbolone.ca/Testings/sqlite3_rdb02.html

Any help would be most appreciated.

--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free 
services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to