Simple and tiny SQLite3 GUI shell for example.
Use sqlite3.dll from PellesC\bin-folder.
This is a startpoint to someone who want to make it better.
EDIT 20110121: message listview
20110212: index list
Hi timovji
I have downloaded your example and am working through it (slowly as yet). Will post an update when I have managed to get some new features working.
Thanks for the great start.
jmac
Thanks for this example. It is very generous of you to present such functionality with simple and clear comments. I am sure it will be of great help to those studying C, windows SDK and SQlite database development. You have also covered printing from the ListView. A great example.
Thanks! Excelent Code......
Updated:
- Execute multiple SQL statements separated with ; (semicolons)
- 32/64-bit
- code can compiled with msvc too ?
Let me know if you find any errors in that code.
Small example for multiple SQL statements:
#include <stdio.h>
#include <stdlib.h>
#include "sqlite3.h"
#ifdef _WIN64
#pragma comment(lib, "SQLite364.lib")
#else
#pragma comment(lib, "SQLite3.lib")
#endif
int __cdecl main(int argc, char **argv)
{
sqlite3 *db;
int rc;
char *szSQL =
"DROP TABLE IF EXISTS test;"
"CREATE TABLE IF NOT EXISTS test (id INTEGER NOT NULL PRIMARY KEY, text VARCHAR(100));"
"INSERT INTO test VALUES (1, 'text1');"
"SELECT * FROM test;";
char *pSQL1, *pSQL2;
rc = sqlite3_open("test.db3", &db);
if (rc == SQLITE_OK)
{
sqlite3_stmt *stmt;
pSQL1 = szSQL; // at start
do
{
rc = sqlite3_prepare_v2(db, pSQL1, -1, &stmt, (const char**)&pSQL2);
if (rc == SQLITE_OK)
{
int nCols = sqlite3_column_count(stmt);
if (nCols)
{
int nCol;
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_name(stmt, nCol));
printf("\n");
while ((rc = sqlite3_step(stmt)) == SQLITE_ROW)
for (nCol = 0; nCol < nCols; nCol++)
printf("%s\t", sqlite3_column_text(stmt, nCol));
printf("\n");
}
sqlite3_finalize(stmt);
} else {
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
break;
}
pSQL1 = pSQL2; // next statement
} while (*pSQL2);
sqlite3_close(db);
} else {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return 1;
}
return 0;
}
EDIT 20110630-22:40: TLSQLite3Shell_WS_0_0_3.zip some fixes
EDIT 20110807: TLSQLite3Shell_WS_0_0_3_1.zip ToolBar bitmap
Development version in TLSQLite3Shell_005_UC_WS.zip
Fixes some old bugs and creates new ones ;)
new features:
- UNICODE version
- menu bitmaps
let me know what errors found in this version :(
a6 fix UNICODE error string
EDIT 2016-09-01: a7 DBExec in thread, escape stop thread
QuoteSELECT Index,Error,Constante,Hexa,Description FROM WindowsErrorCodes;
NEAR "INDEX":SYNTAX ERROR
Could be useful
I just can't understand that error :(
Can you share that database to look at?
PM link to that?
Or just make a better version from that old code and correct bugs ;)
INDEX is a keyword, look here (https://www.sqlite.org/lang_keywords.html).
Use 'index' like this.
Sorry, you are right. In that case the software I use to create the table would not allow such an item.
That could serve to you, if a user create a field with that name you send an error message.
Take a glance at http://sqlitebrowser.org/ (http://sqlitebrowser.org/)
And this one : http://www.sqliteexpert.com/download.html (http://www.sqliteexpert.com/download.html)