When we add data to the database and delete it, the database will become very large after repeated attempts, so we need to compress it.
The following functions can be used to compress databases:
''' <Summary>
''' Compressing the database
''' </Summary>
''' <Remarks> </remarks>
Private sub compactdatabase (byval pfilepath as string)
Dim pfilename as string
Pfilename = getfilename (pfilepath)
'Check whether the database file exists
If Len (Dir (pfilepath) then
'Back Up If you need to back up
If MessageBox. Show ("backup? "," Test ", messageboxbuttons. yesno, messageboxicon. Question) = windows. Forms. dialogresult. yes then
Wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.title = "select Save directory"
Wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.filename = pfilename
Dim pfilter as string = getfileextname (pfilename)
Wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.filter = "file (*." & pfilter & ") | *." & pfilter
Wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.showdialog ()
Dim R as dialogresult = wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.showdialog ()
If R = windows. Forms. dialogresult. Cancel then
Exit sub
End if
Filecopy (pfilepath, wsmanageglobalparam. g_managefilecontrol.savefiledialogfile.filename)
End if
Wsdataset. setnothing ()
Dim jro as jro. jetengine
Dim ptemppath as string = gettemppath ()
Jro = new jro. jetengine ()
Jro. compactdatabase (wsmanageglobalparam. g_connection & pfilepath, wsmanageglobalparam. g_connection & ptemppath & "\" & pfilename)
Kill (pfilepath)
Filecopy (ptemppath & "\" & pfilename, pfilepath)
Kill (ptemppath & "\" & pfilename)
End if