My guess is that you are not connecting to any database file, i.e. calling the 
constructor without a file name AND not calling the openCreateDatabase method 
before attemting to create a table.

BTW:

Your data model assumes a "Name" may have only 1 street address, but up to 4 
telephone numbers and up to 2 email addresses.

This is most certainly inefficient (it duplicates shared information) and -if 
applied to real people - inadequate. Street addresses, phone numbers, and email 
addresses should go into their own tables and be linked via assignment tables.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Papa
Gesendet: Donnerstag, 21. September 2017 10:08
An: SQLite Mailing List <sqlite-users@mailinglists.sqlite.org>
Betreff: [EXTERNAL] [sqlite] Create table - Error code: 21

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


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


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

Reply via email to