Hi gyz,
Am newbie in VB.NET platform, i created windows application with MS Access back-end database.
Now, i want the user to click a button from window form that will automatically copy the database from its original location to a removable media (or even C:\ drive).
I googled this n found the following code:
When i paste it in the event i wanna trigger it, it underlined
with a tooltip sayin "Type 'DAO.DBEngine' not Defined."
I then imported the following:
none of them solves the problem.
help me out please. tnx
Am newbie in VB.NET platform, i created windows application with MS Access back-end database.
Now, i want the user to click a button from window form that will automatically copy the database from its original location to a removable media (or even C:\ drive).
I googled this n found the following code:
VB.NET:
Try
Dim sDBFile As String = "C:\MyDBFolder\db1.mdb"
Dim sBackUpFile As String = "C:\MyDBFolder\BackUp"
If Not System.IO.Directory.Exists(sBackUpFile) Then
System.IO.Directory.CreateDirectory(sBackUpFile)
End If
sBackUpFile &= "\db1BackUp.mdb"
'First check the file u want to compact exists or not
If File.Exists(sDBFile) Then
Dim db As New DAO.DBEngine
'CompactDatabase has two parameters, creates a copy of compact DB at the Destination path
db.CompactDatabase(sDBFile, sBackUpFile)
End If
'restore the original file from the compacted file
If File.Exists(sBackUpFile) Then
File.Copy(sBackUpFile, sDBFile, True)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
When i paste it in the event i wanna trigger it, it underlined
VB.NET:
DAO.DBEngine
I then imported the following:
VB.NET:
Imports Util
Imports HRMS
Imports System.IO
Imports Microsoft
Imports std
Imports CrystalDecisions
none of them solves the problem.
help me out please. tnx