I am developing one c# .NET application.
I am using database of Microsoft Access(OLEDB).
I want to take back up of database time to time (Programatically).
(Or As i can create .bak file in sqlserver2008 r2)
What should i do?
An Access database is usually a single file.
To do a programmatic backup you can simply use a
File.Copy(sourceDbName, destDbName, true);
Of course you can add a simple routine that takes your input database, zip and store it, in your backup directory, optionally passing a password, like this:
using Ionic.Zip;
......
private void BackupToZip(string sourceDBName, string destZipFile, string password)
{
using (ZipFile zip = new ZipFile(destZipFile))
{
if (bkpPass.Length > 0) zip.Password = password;
ZipEntry e = zip.UpdateFile(sourceDbName, string.Empty);
e.Comment = "Working copy stored in date: " + DateTime.Today.ToShortDateString();
zip.Comment = "This zip archive has been created by ......";
zip.Save();
}
}
this snippet of code requires the DotNetZip Library