Hi everybody,
I try to close my db (database)
I have 2 methods (linked with 2 buttons) :
- DB_Ouvrir
- DB_Fermer
// DB_Ouvrir
// 26/04/14 - Méthode pour ouvrir la base de donnée.
// Modifiée :
//
Dim dialog As OpenDialog
Dim file As FolderItem
dialog = New OpenDialog // create the dialog (does not actually show it)
// The filter is what type of file you are looking for
// The filters are defined in the File Types dialog
// inside the edit menu
dialog.Filter = “sqlite” // “text/plain”
dialog.PromptText = “Sélectionner la base de donnée.”// The OpenDialog class supports custom prompts
dialog.Title = “Ouvrir fichier”//
and custom title’s
// Also, you can display the dialogs as sheets
// by calling dlg.showModalWithin(self)
//
// For regular modal dialogs, just call dlg.showModal
file = dialog.ShowModal
//then test for nil to see if the user clicked cancel
If file <> Nil Then
SelectedFolderItemLabel.Text = file.AbsolutePath
Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
'dbFile = GetFolderItem("database_005.sqlite")
dbFile = GetFolderItem(SelectedFolderItemLabel.Text)
db.DatabaseFile = dbFile
If db.Connect Then
'mDB=db
'mDb.DatabaseFile = dbFile
OpenStatusLabel.Text = "SQLite database est ouverte"
Toolbar_11.Tool_Ouvrir.Enabled = False
Toolbar_11.Tool_Fermer.Enabled = True
//proceed with database operations here..
Else
MsgBox("Erreur d'ouverture de la Database : " + db.ErrorMessage)
Toolbar_11.Tool_Ouvrir.Enabled = True
Toolbar_11.Tool_Fermer.Enabled = False
End If
Else
SelectedFolderItemLabel.Text = “User clicked Cancel.”
End If
// DB_Fermer
// 26/04/14 - Méthode pour fermer la base de donnée.
// Modifiée :
// 26/04/14 - Problème avec db.Close
if db.Connect then
If db.Close Then // Base fermée <- Line 7
Toolbar_11.Tool_Ouvrir.Enabled = True
Toolbar_11.Tool_Fermer.Enabled = False
Else // base ouverte
Toolbar_11.Tool_Ouvrir.Enabled = False
Toolbar_11.Tool_Fermer.Enabled = True
End If
msgbox(“base fermée”)
else
msgbox(“Basse non connectée”)
end if
I have a error :
Window1_DB_Fermer, line 7 - This method doesn’t return a value
if db.Close Then // Base fermée
I don’t understand why ?
When I trace on this method, db is nil. Why, normally is declare like SQLiteDatabase
I have on Properties :
Name : db
Type : SQLiteDatabase
Scope : Public
What is false ?