Naja. Wenn ich da ein Buch eintrage erscheint direkt ein Fehler:
Code
--> Function: _SQLite_Exec
--> Query: INSERT INTO datas (ID,Titel,Autor,Verlag,Erscheinungsdatum,Genre,Preis,Einband,ISBN,Seiten,Lagerplatz,Serie,Bestellt,Gelesen,Note,Zusatz,Information,Ausgeliehen_an,Ausgeliehen_am,Ausgeliehen_bis) VALUES ('0','Titel','Author','Verlag','Genre','YYYYMMDD','Genre','','','','','','','','','','','','','','');
--> Error: no such table: datas
Dort steht, dass die Tabelle "datas" nicht existiert.
In Zeile 248 steht ja auch: INSERT INTO datas (ID,...
Deine Tabelle heißt aber anders (Zeile 179): CREATE TABLE IF NOT EXISTS Buchverwaltung(ID...
War der Fehler beseitigt kam als nächster: 21 values for 20 columns beim INSERT
Hab mich mal drangesetzt und nen bisschen was geändert. Hab grad keine Zeit mehr, aber der Anfang der Arrays ist gemacht ![]()
Musst mal bei Zeile 262 gucken, welcher Eintrag da zu viel ist.
AutoIt
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GuiListView.au3>
;Opt
Opt("GUIOnEventMode", 0) ; Du benutzt den MsgLoop-Modus also muss hier "0" stehen oder die Zeile gleich ganz weglassen, weil "0" der Standardwert ist
Global $aSQLCols[]=["ID","Titel","Autor","Verlag","Erscheinungsdatum","Genre","Preis","Einband","ISBN","Seiten","Lagerplatz","Serie","Bestellt","Gelesen","Note","Zusatz","Information","Ausgeliehen_an","Ausgeliehen_am","Ausgeliehen_bis"]
Global $aInputs[][]=[["","Titel"],["","Autor"],["","Verlag"],["","Genre"],["","Erscheinungsdatum"],["","Serie"],["","Preis"], _
["","Lagerplatz"],["","Einband"],["","ISBN"],["","Seiten"],["","Ausgeliehen_an"],["","Ausgeliehen_am"], _
["","Ausgeliehen_bis"],["","Bestellt"],["","Gelesen"],["","Note"],["","Zusatz"],["",""],["",""],["",""],["",""],["",""]]
;GUI Titel
$Buchverwaltung = GUICreate("Buchverwaltung erstellt mit AutoIt", 1121, 629, 280, 183)
; Titel oben Mitte
$Label1 = GUICtrlCreateLabel("~ ~ ~ B U C H V E R W A L T U N G ~ ~ ~", 304, 8, 516, 28)
GUICtrlSetFont(-1, 16, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x0000FF)
$sHeader=""
for $i=0 to UBound($aSQLCols)-1 step 1
$sHeader&=$aSQLCols[$i]&($i<>UBound($aSQLCols)-1?"|":"")
next
; ListView
$listview = GUICtrlCreateListView($sHeader, 10,40,1105,168)
$List1 = GUICtrlCreateList("", 8, 40, 1105, 168)
;~ GUICtrlSetFont(-1, 10, 400, 0, "Arial")
; Hauptbereich
$Label2 = GUICtrlCreateLabel("Titel: ", 10, 274, 45, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[0][0] = GUICtrlCreateInput("", 160, 272, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label3 = GUICtrlCreateLabel("Autor:", 10, 305, 45, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[1][0] = GUICtrlCreateInput("", 160, 302, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label4 = GUICtrlCreateLabel("Verlag: ", 10, 335, 58, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[2][0] = GUICtrlCreateInput("", 160, 332, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label5 = GUICtrlCreateLabel("Genre: ", 10, 365, 55, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[3][0] = GUICtrlCreateInput("", 160, 362, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label6 = GUICtrlCreateLabel("Erscheinungsdatum: ", 10, 395, 149, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[4][0] = GUICtrlCreateInput("YYYYMMDD", 160, 392, 100, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label7 = GUICtrlCreateLabel("Serie: ", 267, 395, 50, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[5][0] = GUICtrlCreateInput("", 313, 392, 208, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label8 = GUICtrlCreateLabel("Preis: ", 10, 424, 146, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[6][0] = GUICtrlCreateInput("", 160, 422, 81, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label9 = GUICtrlCreateLabel("Lagerplatz: ", 267, 424, 85, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[7][0] = GUICtrlCreateInput("", 354, 422, 165, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label10 = GUICtrlCreateLabel("Einband: ", 10, 455, 70, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[8][0] = GUICtrlCreateInput("", 160, 452, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label11 = GUICtrlCreateLabel("ISBN", 10, 485, 40, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[9][0] = GUICtrlCreateInput("", 160, 482, 361, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label12 = GUICtrlCreateLabel("Seiten: ", 10, 514, 57, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[10][0] = GUICtrlCreateInput("", 160, 512, 81, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label13 = GUICtrlCreateLabel("ausgeliehen an: ", 624, 272, 117, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[11][0] = GUICtrlCreateInput("", 760, 272, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label14 = GUICtrlCreateLabel("ausgeliehen am: ", 624, 302, 122, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[12][0] = GUICtrlCreateInput("", 760, 302, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label15 = GUICtrlCreateLabel("ausgeliehen bis: ", 624, 332, 121, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[13][0] = GUICtrlCreateInput("", 760, 334, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label16 = GUICtrlCreateLabel("Bestellt: J/N", 624, 384, 86, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[14][0] = GUICtrlCreateInput("", 760, 384, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label17 = GUICtrlCreateLabel("gelesen: J/N", 624, 414, 90, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[15][0] = GUICtrlCreateInput("", 760, 414, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label18 = GUICtrlCreateLabel("Note: 1 - 6", 624, 444, 76, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[16][0] = GUICtrlCreateInput("", 760, 444, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label19 = GUICtrlCreateLabel("Zusatz:", 624, 474, 53, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[17][0] = GUICtrlCreateInput("", 760, 472, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label20 = GUICtrlCreateLabel("Information:", 896, 384, 84, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Edit1 = GUICtrlCreateEdit("", 896, 408, 217, 89)
$Label22 = GUICtrlCreateLabel("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", 8, 256, 1105, 17)
$Label23 = GUICtrlCreateLabel("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", 8, 544, 1105, 17)
$Button16 = GUICtrlCreateButton("S U C H E N", 621, 509, 132, 25)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[18][0] = GUICtrlCreateInput("Suchbegriff hier eingeben", 760, 507, 347, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label24 = GUICtrlCreateLabel("Lfd.-Nr:", 350, 515, 55, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[19][0] = GUICtrlCreateInput("", 415, 512, 105, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlSetData(-1, "000002")
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
; unterer Bereich
$Label26 = GUICtrlCreateLabel("Büchermenge: ", 13, 595, 113, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[20][0] = GUICtrlCreateInput("", 128, 592, 81, 26) ; hier soll die ges. Bücheranzahl eingefügt werden und nicht veränderbar durch Anwender
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label27 = GUICtrlCreateLabel("Ges. Seitenzahl:", 270, 596, 117, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$aInputs[21][0] = GUICtrlCreateInput(" ", 394, 592, 81, 26) ; hier soll die ges. Seitenzahl eingefügt werden und nicht veränderbar durch Anwender
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Label28 = GUICtrlCreateLabel("Ges. Buch NP:", 572, 595, 106, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlCreateInput("", 680, 592, 121, 26) ; hier soll der ges. Bücherwert eingefügt werden und nicht veränderbar durch Anwender
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Button20 = GUICtrlCreateButton("Speichern", 991, 592, 121, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
; Ausleihbutton
$Button17 = GUICtrlCreateButton("Ausleihen", 888, 272, 227, 25)
; DK 1 / 2 / 3
$Button18 = GUICtrlCreateButton("DK 1 / 2 / 3", 894, 334, 99, 26)
; D 1 / 2
$Button19 = GUICtrlCreateButton("D 1 / 2", 1012, 334, 99, 25)
; GUI anzeigen
GUISetState(@SW_SHOW)
; !!! Datei lösche ich hier nur, damit ich sie nicht manuell löschen muss in der Übungsphase !!!
; FileDelete(@ScriptDir & "\buchverwaltung.db")
; DLL Pfad
_SQLite_Startup(@ScriptDir & "\sqlite3.dll", False, 1) ; BugFix Idee, da DLL ja nicht mehr mitgeliefert wird
; gibt die SQL Version in die Console aus
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
; Datenbank öffnen, ggf. erstellen
Global $g_db_Database = _SQLite_Open(@ScriptDir & "\buchverwaltung.db")
$sCols=""
for $i=1 to UBound($aSQLCols)-1 step 1
$sCols&=$aSQLCols[$i]&($i<>UBound($aSQLCols)-1?",":"")
next
; Datenbanktabelle
_SQLite_Exec($g_db_Database, "CREATE TABLE IF NOT EXISTS Buchverwaltung(ID INTEGER PRIMARY KEY AUTOINCREMENT,"&$sCols&");")
#cs
; jeweils ein Datensatz wird dazu geschrieben, Daten sind von Enno Jüders zur Verfügung gestellt.
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('1','13 Tage','Giambanco, Valentina','Droemer Knaur','2014.03.03','Thriller','14.99','Hardcover','9783426513996','576','R1-F2','','','N','','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('2','Abgründe','Strobel, Arno','Loewe','2014.03.10','Thriller-J','9.95','Taschenbuch','9783785578643','240','R1-F2','','','N','','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('3','Agent 6','Smith, Tom Rob','Goldmann','2011.09.14','Thriller','9.99','Taschenbuch','9783442546770','540','R1-F2','Leo Demidow Bd.3','','N','','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('4','Bedroht','Koppen, Hans','Heyne','2013.03.27','Thriller','14.99','Taschenbuch','9783453268012','411','R1-F2','','','J','1','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('5','Belladonna','Slaughter, Karin','rororo','2003.03.03','Thriller','6.00','Taschenbuch','9783499239140','413','R1-F1','Grant County Bd.1','','J','1','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('6','Bis zum letzten Atemzug','Baldacci, David','Bastei Lübbe','2011.04.01','Thriller','9.99','Taschenbuch','9783404165537','574','R1-F2','King & Maxwell Bd. 4','austauschen','N','','','','','..','..');")
_SQLite_Exec(-1, "INSERT INTO Buchverwaltung VALUES('7','Bittere Wunden','Slaughter, Karin','blanvalet','2014.09.01','Thriller','19.99','Hardcover','9783764505172','576','R1-F1','Georgia Bd.4','','J','2','','','','..','..');")
#ce
Global $hQuery, $aNames, $aRow
_SQLite_Query(-1, "SELECT ROWID,* FROM Buchverwaltung;", $hQuery)
While _SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK ; Read Out the next Row
GUICtrlCreateListViewItem(_ArrayToString($aRow, '|', 1, 17), $listview)
WEnd
_SQLite_QueryFinalize($hQuery)
_GUICtrlListView_RegisterSortCallBack($listview) ; CallBack registrieren zum sortieren
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $listview
_GUICtrlListView_SortItems($listview, GUICtrlGetState($listview)) ; hier wird das Listview sortiert
Case $Button20
$ID =_SQLite_TotalChanges()
_ds_plus($id)
EndSwitch
WEnd
Func _Exit() ; Datenbank schließen und down.
_GUICtrlListView_UnRegisterSortCallBack($listview)
_SQLite_Close($g_db_Database)
_SQLite_Shutdown()
EndFunc
; Datensatz von GUI2DB
Func _ds_plus($id)
Local $aworte
$inputs1 = GUICtrlRead($aInputs[0][0]) ; Titel
$inputs2 = GUICtrlRead($aInputs[1][0]) ; Autor
$inputs3 = GUICtrlRead($aInputs[2][0]) ; Verlag
$inputs5 = GUICtrlRead($aInputs[4][0]) ; Erscheinungsdatum
$inputs4 = GUICtrlRead($aInputs[3][0]) ; Genre
$inputs7 = GUICtrlRead($aInputs[6][0]) ; Preis
$inputs9 = GUICtrlRead($aInputs[8][0]) ; Einband
$inputs10 = GUICtrlRead($aInputs[9][0]) ; ISBN
$inputs11 = GUICtrlRead($aInputs[10][0]) ; Seiten
$inputs8= GUICtrlRead($aInputs[7][0]) ; Lagerplatz
$inputs6 = GUICtrlRead($aInputs[5][0]) ; Serie
$inputs15 = GUICtrlRead($aInputs[14][0]) ; Bestellt
$inputs16 = GUICtrlRead($aInputs[15][0]) ; Gelesen
$inputs17 = GUICtrlRead($aInputs[16][0]) ; Note
$inputs18 = GUICtrlRead($aInputs[17][0]) ; Zusatz
$edits1 = GUICtrlRead($Edit1) ; Information <------- ???
$inputs12 = GUICtrlRead($aInputs[11][0]) ; Ausgeliehen_an
$inputs13 = GUICtrlRead($aInputs[12][0]) ; Ausgeliehen_am
$inputs14 = GUICtrlRead($aInputs[13][0]) ; Ausgeliehen_bis
_SQLite_QuerySingleRow(-1,"SELECT id FROM Buchverwaltung WHERE id='"&$id&"'",$aworte)
If $aworte[0] <> "" Then
_SQLite_Exec(-1,"UPDATE Buchverwaltung SET Titel='"&$inputs1&"', Autor='"&$inputs2&"',Verlag='"&$inputs3&"', Erscheinungsdatum='"&$inputs5&"', Genre='"&$inputs4&"',Preis='"&$inputs7&"',Einband='"&$inputs9&"',ISBN='"&$inputs10&"',Seiten='"&$inputs11&"',Lagerplatz='"&$inputs8&"',Serie='"&$inputs6&"',Bestellt='"&$inputs15&"',Gelesen='"&$inputs16&"',Note='"&$inputs17&"',Zusatz='"&$inputs18&"', Information='"&$edits1&"',Ausgeliehen_an='"&$inputs12&"',Ausgeliehen_am='"&$inputs13&"',Ausgeliehen_bis='"&$inputs14&"' WHERE id='"&$id&"'")
Else
_SQLite_Exec(-1,"INSERT INTO Buchverwaltung (ID,Titel,Autor,Verlag,Erscheinungsdatum,Genre,Preis,Einband,ISBN,Seiten,Lagerplatz,Serie,Bestellt,Gelesen,Note,Zusatz,Information,Ausgeliehen_an,Ausgeliehen_am,Ausgeliehen_bis) VALUES ('"&$id&"','"&$inputs1&"','"&$inputs2&"','"&$inputs3&"','"&$inputs4&"','"&$inputs5&"','"&$inputs4&"','"&$inputs7&"','"&$inputs9&"','"&$inputs10&"','"&$inputs11&"','"&$inputs8&"','"&$inputs6&"','"&$inputs15&"','"&$inputs16&"','"&$inputs17&"','"&$inputs18&"','"&$edits1&"','"&$inputs12&"','"&$inputs13&"','"&$inputs14&"');")
EndIf
_GUICtrlListView_SortItems($listview, GUICtrlGetState($listview))
EndFunc
Alles anzeigen
MfG Kanashius