#Region Project Attributes
#AdditionalJar: ucanaccess-5.0.0.jar
#AdditionalJar: hsqldb-2.5.0.jar
#AdditionalJar: jackcess-3.0.1.jar
#AdditionalJar: commons-logging-1.2.jar
#AdditionalJar: commons-lang3-3.8.1.jar
#End Region
Sub Process_Globals
Private fx As JFX
Public DBFile As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
'DBFile = File.DirApp & "\" & "money.mdb"
DBFile = "C:\DB\db.mdb"
If CreateDba(DBFile, False, "V2000", True, False, True)=False Then
fx.Msgbox(Form1, "Error create bd!", "Problems !")
Else
fx.Msgbox(Form1, "Bd created!", "Great !")
End If
Form1.Close
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Public Sub CreateDba(DBFile_ As String, Pmemory As Boolean, PnewDatabaseVersion As String, PshowSchema As Boolean, PopenExclusive As Boolean, PpreventReloading As Boolean) As Boolean
'DBFile - the path to the database *.mdb (расположение файла *.mdb)
'True/False - its backing database only in memory (резервная копия БД только в памяти)
' Format BD (V2000, V2003, V2007, V2010) (формат новой БД)
'True/False - showSchema (схема БД)
'True/False - openExclusive (монопольный доступ)
'True/False - preventReloading (оптимизация при работе совместно с другими интерфейсами)
Log("Database file: " & DBFile)
Dim Result As Boolean
Dim ConDba_ As SQL
Try
Log(" Init sql connection...")
ConDba_.Initialize("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://" & DBFile & _
";memory=" & Pmemory & ";newDatabaseVersion=" & PnewDatabaseVersion & ";showSchema=" & PshowSchema & ";openExclusive=" & PopenExclusive & ";preventReloading=" & PopenExclusive)
Result = True
Catch
Log(LastException.Message)
Result = False
End Try
Return Result
End Sub