English
SDK-aide/ Tools

SQLite Return with slExec, X4, with Testprogamm (too for Beginner)

 

Herby
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.

24 kB
Hochgeladen:07/24/19
Downloadcounter92
Download
 
XProfan X4
Win 10, XProfan X2/X3 jetzt X4
07/24/19  
 



have the Topic time to SDK-aide/ Tools moved.
 
09/24/20  
 




funkheld
Hm....what should Roland with the Program?

means not for the low-down people from Germany separate only for bavaria and Roland?

greeting
 
01/08/22  
 



Sub-Topic: IN-MEMORY - DB  [...]  created.
 
04/12/23  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.296 Views

Untitledvor 0 min.
Matzbub02/03/24
Thomas Zielinski06/28/23
Paul Glatz06/22/23
E.T.06/12/23
More...

Themeninformationen

this Topic has 4 subscriber:

H.Brill (1x)
funkheld (1x)
iF (1x)
Herby (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie