Code : Tout sélectionner
UseSQLiteDatabase()
fichier_plante_db.s = "test.db"
If OpenDatabase(1, fichier_plante_db, "", "")
;Debug "Connecté à PureBasic.sqlite"
; If DatabaseUpdate(0, "CREATE TABLE travaux (id int,date int, description varchar, type_plante varchar, photo varchar, meteo varchar, prix varchar, quantite varchar,autres varchar);")
If DatabaseUpdate(1, "CREATE TABLE plantes (id_plante int,description_plante varchar, floraison_plante varchar, annee_plante varchar, photo_plante varchar,prix_plante varchar,hauteur_plante varchar);")
;Debug "Table cree"
EndIf
Else
If CreateFile(1,fichier_plante_db)
CloseFile(1)
If OpenDatabase(1, fichier_plante_db, "", "")
If DatabaseUpdate(1, "CREATE TABLE plantes (id_plante int,description_plante varchar, floraison_plante varchar, annee_plante varchar, photo_plante varchar,prix_plante varchar,hauteur_plante varchar);")
;Debug "Connecté à PureBasic.sqlite"
;If DatabaseUpdate(0, "CREATE TABLE travaux (id int,date int, description varchar, type_plante varchar, photo varchar, meteo varchar, prix varchar,quantite varchar,autres varchar );")
;Debug "Table cree"
EndIf
EndIf
EndIf
EndIf
requete_ajout$="INSERT INTO plantes VALUES ('','attention','','','','','')"
DatabaseUpdate(1, requete_ajout$)
Ce code fonctionne mais si l'on insère une apostrophe dans une valeur cela ne marche plus, comment éviter cela ?
Code qui ne marche pas
Code : Tout sélectionner
UseSQLiteDatabase()
fichier_plante_db.s = "test.db"
If OpenDatabase(1, fichier_plante_db, "", "")
;Debug "Connecté à PureBasic.sqlite"
; If DatabaseUpdate(0, "CREATE TABLE travaux (id int,date int, description varchar, type_plante varchar, photo varchar, meteo varchar, prix varchar, quantite varchar,autres varchar);")
If DatabaseUpdate(1, "CREATE TABLE plantes (id_plante int,description_plante varchar, floraison_plante varchar, annee_plante varchar, photo_plante varchar,prix_plante varchar,hauteur_plante varchar);")
;Debug "Table cree"
EndIf
Else
If CreateFile(1,fichier_plante_db)
CloseFile(1)
If OpenDatabase(1, fichier_plante_db, "", "")
If DatabaseUpdate(1, "CREATE TABLE plantes (id_plante int,description_plante varchar, floraison_plante varchar, annee_plante varchar, photo_plante varchar,prix_plante varchar,hauteur_plante varchar);")
;Debug "Connecté à PureBasic.sqlite"
;If DatabaseUpdate(0, "CREATE TABLE travaux (id int,date int, description varchar, type_plante varchar, photo varchar, meteo varchar, prix varchar,quantite varchar,autres varchar );")
;Debug "Table cree"
EndIf
EndIf
EndIf
EndIf
requete_ajout$="INSERT INTO plantes VALUES ('','à l'attention','','','','','')"
DatabaseUpdate(1, requete_ajout$)