I read my newly created database using this method:
void Runner::read_tblName() {
.
sql_statement = "SELECT * FROM name";
db->setStmt(sql_statement);
int pos = 0;
data1 = db->read_int(pos);
db->setStmt(sql_statement);
pos = 1;
data2 = db->read_str(pos);
data3 = db->read_str(++pos);
data4 = db->read_str(++pos);
data5 = db->read_str(++pos);
Glib::ustring str;
str = apstr.format(data1);
str += " ";
str += data2;
str += ". ";
str += data3;
str += " ";
str += data4;
str += " ";
str += data5;
apex->setException(str, FILE, METHOD, LINE);
apex->Display();
}
const int mySQLite3::read_int(int pos)
throw(somexception) {
rc = sqlite3_prepare_v2(db, SQLStatement.c_str(), -1, &mystmt, NULL);
if(rc != SQLITE_OK) {
try {
this->display(rc, FILE, METHOD, LINE);
} catch(somexception e) {
throw e;
}
} else {
counter++;
}
rc = sqlite3_step(mystmt);
if(rc == SQLITE_ROW ) {
apint = sqlite3_column_int(mystmt,pos);
}
try {
this->finalize();
} catch(somexception& e) {
throw e;
}
return apint;
}
const Glib::ustring& mySQLite3::read_str(const int pos)
throw(somexception) {
//if(pos == 0) {
rc = sqlite3_prepare_v2(db, this->SQLStatement.c_str(), -1, &mystmt,
NULL);
//}
if(rc != SQLITE_OK) {
try {
this->display(rc, FILE, METHOD, LINE);
} catch(somexception e) {
throw e;
}
} else {
counter++;
}
rc = sqlite3_step(mystmt);
if(rc == SQLITE_ROW ) {
apstr = (const char*)sqlite3_column_text(mystmt,pos);
}
try {
this->finalize();
} catch(somexception& e) {
throw e;
}
return apstr;
}
This works just fine, but it only reads the first row, how can I 'tell' my
program HOW MANY rows are there to be read and which row I WANT TO READ?
Is there a function in SQLite3 that would help me do this?
... work out your salvation with fear and trembling
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users