Attribute VB_Name = "Module2"
Option Explicit
  
Public xfile As Classe_Fichier_FSO
Public Base As Database


Public DB_file_Extension As String
Public DB_file As String
Public DB_path As String
Public DB_ConnectionString As String
Public DB_IsConnected As Boolean
Dim fso As FileSystemObject

Public Enum ListAction
    Selection = 0
    Connection
    Deconnection
End Enum

Public Sub Connect()

    DB_IsConnected = False
On Error GoTo fin
    Set Base = OpenDatabase(DB_path & "\" & DB_file & "." & DB_file_Extension, False, False, "MS Access;PWD=suivi")
    
    DB_IsConnected = True
    Call Form2.ActionFrame(DeConnexion)
    Exit Sub
fin:
    DB_IsConnected = False
    Call Form2.ActionFrame(SelectionBase)
End Sub

Public Sub UnConnect()
On Error Resume Next
    Base.Close
    DB_IsConnected = False
End Sub

  
Sub InitConnection(fullPath As String)

  'Procedure qui construit la chaine de connection


    DB_file_Extension = xfile.getFileExtension(fullPath)
    
    
    DB_file = xfile.getFileName(fullPath)
    
    If DB_file_Extension <> "" Then
        DB_file = Replace(DB_file, "." & DB_file_Extension, "")
    Else
        DB_file = DB_file
    End If
    
    
    If DB_file_Extension <> "" Then
    
        DB_path = Replace(fullPath, "\" & DB_file & "." & DB_file_Extension, "")
    Else
        DB_path = Replace(fullPath, "\" & DB_file, "")
    End If
   
    
    
    DB_ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & fullPath

    

End Sub

Sub FinConnection()
    If DB_IsConnected Then UnConnect

End Sub

