Hello all and particularly on Roland.
enclosed one Demoprogramm for the Rückgabewerte with "slExec", the at the same time as Testprogramm for Grundlagen of SQLite serves. It's all right thereby around the Rückgabewerte with one slExec - commands. here becomes only Select The Number of found Datensätze zurückgegeben otherwise always 0 (with Fehlern discontinue) is it here possible too with all others command (Insert,Delete,Update,Count) a worth To supplying or vielleich there the already what about me white not ?
back SQLite : <Die Number of of SQLEXEC bearbeiteten Datensätze is the Result the function and becomes too in &SQLCount zurückgeliefert. entered Error on, becomes -1 zurückgegeben.> this schein but only over The ODBC-interface To functions (have I but not).
this would optimal the with Fehlern -1 comes and then too $SQLError staid becomes, otherwise even The amount. therefore could then fehlerhafte command abgefangen go without Programmabbruch. particularly interestingly is the with one TRIGGER and RAISE where bestimme Events quizzed go can and then too informations created go (see Program beu DB_Open). the example with clear area could one too in Profan solve, but there's there certainly yet More Opportunities. as equipment Image the (Error)Message of SQL "Name is leer"
' Testprogramm for SQLite, XProfan X4, maggot by Herby
Declare grid&, g&, Text&, Ende&, ins&, leer&, Del&, such&, DB&
Declare zwi$, zwi%, erg%, end%
' data base produce, if No, and link produce ************
Proc DB_Open
ifnot fileexists("testdb.db")
db& = db("slCreate", "testdb.db")
Db("slExec", DB&, "CREATE TABLE data (Id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, date REAL)",1)
db("slExec", DB&, "INSERT INTO data (Id, name, date) VALUES (1, 'set 1',JULIANDAY('NOW','LOCALTIME'))", 1)
' Trigger create if Datensatz with clear names eingefügt becomes, goes too with Delete, Update. or Logdatei create with Changes ...
Db("slExec", DB&, "CREATE TRIGGER Name_leer BEFORE INSERT ON data BEGIN SELECT CASE WHEN NEW.name = '' THEN RAISE ( ABORT, 'name is empty') END; END;",1)
MessageBox("Datenbank new erstellt","Hinweis",64)
else
db& = db("slInit", "testdb.db")
EndIf
ENDPROC
' any Sätze from data base reading and Grid Show ******************************
Proc DB_Read
ClearList 0
ClearList grid&, g&
erg% = Db("slExec", DB&, "SELECT Id, name, DATE(date), TIME(date) FROM Daten",g&)
Printx "Lesen : ",erg%
Move("HandleToList",g&)' in Grid go only Datensätze registered without Überschriften/Spaltenbeiten, therefore over Grid !
Move("ListToHandle",grid&)' in gridBOX go The Überschriften and Column of SQL staid
ENDPROC
' Text in ListBox spend and on latest row positionieren (terminal) **********
Proc Printx
Parameters TEXT$,Nr%
AddStrings(Text&,TEXT$ + Str $(Nr%))
Select String(Text&,GetCount(Text&)-1,"")
ENDPROC
cls
db("slUseDLL", "sqlite3.dll")' DLL initialisieren
DB_Open
g& = create("Grid",4,0)' here go data headless line registered
Grid& = Create("gridbox",%hwnd,"ID;0;30;Name;0;200;Datum;0;70;Zeit;0;70",0,200,20,400,200)
Text& = create("Listbox",%hwnd,0,20,20,150,200)
Del& = Create("Button",%hwnd,"Del",200,360,60,25)
Ins& = Create("Button",%hwnd,"Ins",300,360,60,25)
Leer& = Create("Button",%hwnd,"Leer",400,360,60,25)
Ende& = Create("Button",%hwnd,"Ende",500,360,60,25)
DB_Read
Randomize
WhileNot end%
WaitInput
If Clicked(Ende&)
end% = 1
ElseIf Clicked(Ins&)' Insert Record
ZWI$ = "Test " + Str $(Rnd(1000)+1)
erg% = Db("slExec", DB&, "INSERT INTO data (name,date) VALUES (:zwi$,JULIANDAY('NOW','LOCALTIME'))",1)
Printx "Ins : ",erg%
DB_Read
Select String(grid&,GetCount(grid&)-1,"")
ElseIf Clicked(Leer&)' Insert Record with clear names, fractures with SQL-Error [19] ex, evtl erg% settle ($sqlerror/&sqlcount ?!?)
erg% = Db("slExec", DB&, "INSERT INTO data (name,date) VALUES ('',JULIANDAY('NOW','LOCALTIME'))",1)
Printx "Ins empty : ",erg%
DB_Read
ElseIf Clicked(Del&)' marked Datensatz delete
ZWI% = GetCurSel(grid&)
If ZWI% > -1
ZWI% = Val(GetText$(grid&,ZWI%,0))' Id from selectierten Datensatz reading
erg% = Db("slExec", DB&, "DELETE FROM data WHERE Id = :zwi%",1)
Printx "Del : ",erg%
DB_Read
Select String(grid&,GetCount(grid&)-1,"")
EndIf
EndIf
EndWhile
DB("slDone", DB&)' data base close
End
Regards from munich of Herby. |