Home » Community » Newbie corner » Need help with SQL code
Need help with SQL code [message #36627] |
Thu, 21 June 2012 18:32 |
lectus
Messages: 329 Registered: September 2006 Location: Brazil
|
Senior Member |
|
|
Hello!
I tried this simple code:
void MainWindow::BtnAddPush()
{
String name = ~editName;
String phone = ~editPhone;
arr.Add(name, phone);
Sqlite3Session sqlite3ses;
if (!sqlite3ses.Open("test.db")) {
printf("Couldn't open database!");
return;
}
Sql sql(sqlite3ses);
sql.ClearError();
sql.Execute("INSERT INTO PHONEBOOK VALUES(?,?);", name, phone);
sqlite3ses.Close();
}
void MainWindow::BtnRefreshPush()
{
Sqlite3Session sqlite3ses;
if (!sqlite3ses.Open("test.db")) {
printf("Couldn't open database!");
return;
}
Sql sql(sqlite3ses);
sql.ClearError();
sql.Execute("SELECT * FROM PHONEBOOK;");
while(sql.Fetch()) {
arr.Add(sql[0], sql[1]);
}
sqlite3ses.Close();
}
MainWindow::MainWindow()
{
CtrlLayout(*this, "Window title");
arr.AddColumn("Name");
arr.AddColumn("Phone");
btnAdd.WhenPush = THISBACK(BtnAddPush);
btnRefresh.WhenPush = THISBACK(BtnRefreshPush);
}
GUI_APP_MAIN
{
MainWindow().Run();
}
It compiles fine. But when I click the 'Refresh' button I get an error. What's wrong?
The error message is: "Assertion failed in Sqlite3upp.cpp, line 361 SQLITE_OK == retval".
PS: The 'test.db' database already exists (created by sqlite3 command line tool).
|
|
|
Goto Forum:
Current Time: Tue May 21 02:32:55 CEST 2024
Total time taken to generate the page: 0.02459 seconds
|