'Il faut d'abord ajouter la référence ADOX (menu "Projet/Références/COM..." puis sélectionner "Microsoft ADO Ext. 2.8 for DDL and Security"). Public Class Form1 Dim cat As New ADOX.Catalog Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try If (("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") Is Nothing) Then Else cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") MsgBox("Base créer") End If Catch End Try End Sub End Class
Try If (("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\Film.accdb") Is Nothing) Then MsgBox("Base existante") Else MsgBox("Base inexistante") MsgBox("Création de la base de données : FILM", MessageBoxIcon.Information, MessageBoxButtons.OK) db.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\Film.accdb") MsgBox("Base créer") End If Catch End Try
'Il faut d'abord ajouter une référence à ADOX (menu "Projet/Références/COM..." puis sélectionner "Microsoft ADO Ext. 2.8 for DDL and Security"). Public Class Form1 Dim cat As New ADOX.Catalog Dim existe As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try If (("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") Is Nothing) Then existe = False Else cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") MsgBox("Base créer") End If Catch If existe = False Then MsgBox("Base déjà créer") End If End Try End Sub End Class
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question'Il faut d'abord ajouter une référence à ADOX (menu "Projet/Références/COM..." puis sélectionner "Microsoft ADO Ext. 2.8 for DDL and Security"). Public Class Form1 Dim cat As New ADOX.Catalog Dim existe As Boolean Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try If (("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") Is Nothing) Then existe = True Else cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Application.Info.DirectoryPath & "\MyDataBase.mdb") MsgBox("Base créer") End If Catch If existe = True Then MsgBox("Base déjà créer") End If End Try End Sub End Class
If System.IO.File.Exists("film.accdb") Then MsgBox("Base existante") Else MsgBox("Base inexistante") MsgBox("Création de la base de données : FILM", MessageBoxIcon.Information, MessageBoxButtons.OK) db.Create("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath & "\Film.accdb") MsgBox("Base créer") End If