Je débute un peut sur la gestion de base de données sqlite et je rencontre un problème au moment de la création de mes tables. Voici ma procédure
Code : Tout sélectionner
Procedure DBMC_Init()
Protected plFile.l
Protected psSQLRequest.s
UseSQLiteDatabase()
If FileSize("MC.sqlite") < 0
plFile = CreateFile(#PB_Any, "MC.sqlite")
If plFile
CloseFile(plFile)
EndIf
EndIf
glDBSQLite = OpenDatabase(#PB_Any, "MC.sqlite", "", "", #PB_Database_SQLite)
If glDBSQLite = 0
MessageRequester("Evènement main courante", DatabaseError())
End
ElseIf plFile
psSQLRequest = "CREATE TABLE IF NOT EXISTS maincourante ("
psSQLRequest + "id_maincourante INTEGER PRIMARY KEY AUTOINCREMENT Not NULL, "
psSQLRequest + "maincourante_auteur TEXT Not NULL, "
psSQLRequest + "maincourante_date TEXT Not NULL, "
psSQLRequest + "maincourante_heure TEXT Not NULL, "
psSQLRequest + "maincourante_categorie TEXT Not NULL, "
psSQLRequest + "maincourante_lieu TEXT Not NULL, "
psSQLRequest + "maincourante_requerant TEXT Not NULL, "
psSQLRequest + "maincourante_sujet TEXT Not NULL, "
psSQLRequest + "maincourante_commantaires TEXT Not NULL"
psSQLRequest + "maincourante_photo BLOB, "
psSQLRequest + "maincourante_photo_size INTEGER"
psSQLRequest + ")"
; Debug psSQLRequest
If DatabaseUpdate(glDBSQLite, psSQLRequest) = 0
MessageRequester("Evènement main-courante - DBMC_Init()", DatabaseError())
EndIf
EndIf
If DatabaseQuery(glDBSQLite, "SELECT * FROM maincourante") <> 0
While NextDatabaseRow(glDBSQLite)
AddGadgetItem(#ExplorerMC, CountGadgetItems(#ExplorerMC), GetDatabaseString(glDBSQLite, 0) + Chr(10) + GetDatabaseString(glDBSQLite, 1) + Chr(10) + GetDatabaseString(glDBSQLite, 2) + Chr(10) + GetDatabaseString(glDBSQLite, 3) + Chr(10) + GetDatabaseString(glDBSQLite, 4) + Chr(10) + GetDatabaseString(glDBSQLite, 5) + Chr(10) + GetDatabaseString(glDBSQLite, 6) + Chr(10) + GetDatabaseString(glDBSQLite, 7) + Chr(10) + GetDatabaseString(glDBSQLite, 8))
SetGadgetItemData(#ExplorerMC, CountGadgetItems(#ExplorerMC)-1, GetDatabaseLong(glDBSQLite, 0))
Wend
FinishDatabaseQuery(glDBSQLite)
EndIf
EndProcedure