Hi can
anyone help me with the correct C# code to create a .bak
file / a backup of an ms-access 2003 dataBase ?!. I tried using the code posted here on a seperate thread but I get the exception saying ;
Invalid SQL Statement;expected
'DELETE','INSERT','PROCEDURE','SELECT' or 'UPDATE'
The Following is the Code I've Used To backup the DataBase.
//Event Calling the DataBase Backup Method
private void bkUpDB_Click(object sender, EventArgs e)
{
try
{
//Calling the Method Backing Up the DataBase
this.createBackup();
}
catch
(Exception ex)
{
MessageBox.Show(this, ex.Message,
"Error Backing Up the DataBase");
}
}
//Method Backing Up the DataBase
public void createBackup()
{
//The
Current DataBase Connection String
string conStr = "Provider = Microsoft.jet.oledb.4.0;Data
Source =C:\...\Inventory.mdb;User Id=Admin;Jet OLEDB : Database Password=123123";
//The
Path of the Current DataBase
string dbCurrentPath = "C\...\Inventory.mdb";
//Passing
the Connection String To the OledbConnector
OleDbConnection con = new OleDbConnection(conStr);
//The Query
Used To Create the database Backup
string oQuery = "Backup database " + dbCurrentPath
+ " To disk="F:\...\Inventory.bak";
OleDbCommand com = new OleDbCommand(oQuery, con);
con.Open();
try
{
com.ExecuteNonQuery();
con.Close();
com = null;
oQuery = "";
}
catch
(Exception ex)
{
MessageBox.Show(this, ex.Message,
"Error Backing Up the DataBase", MessageBoxButtons.OK, MessageBoxIcon.Error);
con.Close();
com = null;
oQuery = "";
}
}
-- Please Help This is very very urgent !!.
Thanks In advance !!.
M.Shehan Ramesh
Perera