25-07-20, 02:24 PM
(آخر تعديل لهذه المشاركة : 25-07-20, 02:25 PM {2} بواسطة ahmedbezia.)
كود :
Public Sub CompactAccessDBT(ByVal connectionString As String, ByVal mdwfilename As String)
Try
Dim Engine = CreateObject("JRO.JetEngine")
Engine.CompactDatabase("provider=microsoft.ace.oledb.12.0;" & "Data Source=" & Application.StartupPath & "\AUTO.mdb;" & "Jet OLEDB:Database Password=AHMED1998;" & _
"Jet OLEDB:Engine Type=5;", _
"provider=microsoft.ace.oledb.12.0;" & _
"Jet OLEDB:Database Password=AHMED1998;" & _
"Data Source=" & Application.StartupPath & "\AUTO.mdb.tmp" & ";" & _
"Jet OLEDB:Engine Type=5;")
Dim FullPath As String = IO.Path.GetDirectoryName(Application.StartupPath & "\AUTO.mdb")
IO.File.Delete(Application.StartupPath & "\AUTO.mdb")
Dim filename As String = IO.Path.GetFileName(Application.StartupPath & "\AUTO.mdb.accdb" & ".tmp")
Dim GetFileNameWithoutExtension As String = IO.Path.GetFileNameWithoutExtension(Application.StartupPath & "\AUTO.mdb" & ".tmp")
FileSystem.Rename(Application.StartupPath & "\AUTO.mdb" & ".tmp", FullPath & "\" & GetFileNameWithoutExtension)
Catch ex As Exception
If InStr(ex.Message.ToUpper, "password".ToUpper) Or InStr(ex.Message.ToUpper, "password".ToUpper) Then
MsgBox("Password is invalid.", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Password Database")
ElseIf My.Computer.FileSystem.FileExists(Application.StartupPath & "\AUTO.mdb") = False Then
MsgBox("Database Not found!", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Erorr")
Else
MsgBox("Pressure operation failed!, Be sure not to open the database from another source.", MsgBoxStyle.OkOnly + MsgBoxStyle.Critical, "Erorr")
End If
End Try
End Sub
اريد اين المشكل في هد الكود ضغط واصلاح قاعدة بينات اكسس 2003