#include once "sqlite3.bi" #define NULL 0 Dim As sqlite3 Ptr db Dim As sqlite3_stmt Ptr stmt Dim As Integer rc ' Open database file rc = sqlite3_open("players.sqlite3", @db) If rc <> SQLITE_OK Then Print "No se puede abrir la base de datos: "; *sqlite3_errmsg(db) sqlite3_close(db) End 1 End If ' Delete old database if it exists sqlite3_exec(db, "DROP TABLE IF EXISTS players;", NULL, NULL, NULL) ' Create database table with sample data sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS players (name TEXT NOT NULL, score INTEGER, active BIT, jerseyNum INTEGER);", NULL, NULL, NULL) sqlite3_exec(db, "INSERT INTO players VALUES ('Jones, Bob',0,'N',99)", NULL, NULL, NULL) sqlite3_exec(db, "INSERT INTO players VALUES ('Jesten, Jim',0,'N',100)", NULL, NULL, NULL) sqlite3_exec(db, "INSERT INTO players VALUES ('Jello, Frank',0,'N',101)", NULL, NULL, NULL) ' Update name and score of player with jersey number 99 sqlite3_exec(db, "UPDATE players SET name = 'Smith, Steve', score = 42, active = 'TRUE' WHERE jerseyNum = 99;", NULL, NULL, NULL) ' Query and display all player table records Dim As sqlite3_stmt Ptr stmt2 Dim As String query3 = "SELECT * FROM players" rc = sqlite3_prepare_v2(db, Strptr(query3), -1, @stmt2, 0) While sqlite3_step(stmt2) = SQLITE_ROW Print "['"; *Cptr(ZString Ptr, sqlite3_column_text(stmt2, 0)); "', "; Print *Cptr(ZString Ptr, sqlite3_column_text(stmt2, 1)); ", "; Print *Cptr(ZString Ptr, sqlite3_column_text(stmt2, 2)); ", "; Print sqlite3_column_int(stmt2, 3); "]" Wend ' Close the database sqlite3_finalize(stmt2) sqlite3_close(db) Sleep