Antwort auf: Einfacher Login mit MySql Datenbank

Startseite Foren Deutsches LiveCode-Forum Einfacher Login mit MySql Datenbank Antwort auf: Einfacher Login mit MySql Datenbank

#14836
Herby
Teilnehmer

    Hallo JB,

    ich arbeite mit einer SQLite-Datei (intern) auf einem einem Android-Smartphone.
    Als Beispiel poste ich hier meine Änderungsroutine:

    
    global ypfd -- Pfad zur SQLite-Datei
    global xlan --Ändern
    
    on mouseUp 
       
       if fld "fdlax" > 0 then  -- Eingabe vorhanden ?
          if xlan = false then
             set the itemDelimiter to tab
             put fld "fdlax" into z1 -- (Datensatz-ID)
             put revOpenDatabase("sqlite",ypfd, , , , ) into xsql -- Datensatz suchen und anzeigen
             put "SELECT Karte1,Karte2 FROM Stapel WHERE ID = " &z1 into xsel
             put revDataFromQuery(tab,return,xsql,xsel) into xdat
             put textDecode(xdat,"UTF-8") into Texte  -- Umlaute umwandeln
             put Texte into xdat
             revCloseDatabase xsql
             if xdat is not empty then -- Gibt es den Datensatz mit der eingegebenen ID ?
                put item 1 of xdat into fld "fdlay"
                put item 2 of xdat into fld "fdlaz"
                set the disabled of fld "fdlax" to true
                set the disabled of fld "fdlay" to false
                set the disabled of fld "fdlaz" to false
                set the label of button "bnlae" to "Speichern"
                set the disabled of btn "bnlei" of card id 76194 to true
                set the disabled of btn "bnllo" of card id 76194 to true
                put true into xlan
             else
                put "Datensatz ID nicht gefunden" into fld "fdlay"
                wait 3 seconds
                LKLoeschen -- Alles zurücksetzen
             end if
          else
             if fld "fdlay" is empty or fld "fdlaz" is empty then -- keine Eingaben gemacht
                LKLoeschen
             end if
             if fld "fdlay" is not empty and fld "fdlaz" is not empty then
                put fld "fdlax" into x1 -- Datensatz-ID
                put textEncode(fld "fdlay","UTF-8") into k1
                put textEncode(fld "fdlaz","UTF-8") into k2
                put revOpenDatabase("sqlite",ypfd, , , , ) into xsql --- Datensatz ändern
                put "UPDATE Stapel SET Karte1 = '" &k1& "', Karte2 = '" &k2& "' WHERE ID = "&x1 into sql
                revExecuteSQL xsql, sql
                revCloseDatabase xsql
                
                put revOpenDatabase("sqlite",ypfd, , , , ) into xsql --(alle Datensätze neu anzeigen)
                put "SELECT ID,Karte1,Karte2 FROM Stapel" into xsel
                put revDataFromQuery(tab,return,xsql,xsel) into xxerg
                put textDecode(xxerg,"UTF-8") into xerg
                revCloseDatabase xsql
                set the dgtext of group "DataK" to xerg
                LKLoeschen
             end if
          end if
       else
          put "Bitte Datensatz ID eingeben" into fld "fdlay"
          wait 3 seconds
          LKLoeschen
       end if
       
    end mouseUp
    
    

    für mySQl müsstest du nur die Anmeldung ändern :

    put revOpenDatabase(„mysql“, „www.server.com“, dbName, userName, passWort) into dbid

    Ich habe meine Infos beim LiveCode-Papst (Hauke Fehr) gefunden:

    Keine Angst vor Datenbanken – eine kleine Einführung

    Beste Grüße
    Herby