#region Delete Last data from MS Access Database
public bool DeleteLastDataFromAccess(int iLastIdInAccess, string strMWPath)
{
string[] strSplitedArr = strMWPath.Split('\\');
strSplitedArr = strSplitedArr.Where(w => w != strSplitedArr[3]).ToArray();
string strMapPath = strSplitedArr[0] + "\\" + strSplitedArr[1] + "\\" + strSplitedArr[2];
strMapPath = strMapPath + "\\Plugins";
try
{
string sql = " DELETE FROM wgn_US WHERE [OID] =" + iLastIdInAccess;
OleDbConnection My_Connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strMapPath + @"\MWSWAT\mwswat.mdb;;Persist Security Info=False;");
if (My_Connection.State == ConnectionState.Closed)
{
My_Connection.Open();
}
OleDbCommand My_Command = new OleDbCommand(sql, My_Connection);
My_Command.ExecuteNonQuery();
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
return true;
}
#endregion
public bool DeleteLastDataFromAccess(int iLastIdInAccess, string strMWPath)
{
string[] strSplitedArr = strMWPath.Split('\\');
strSplitedArr = strSplitedArr.Where(w => w != strSplitedArr[3]).ToArray();
string strMapPath = strSplitedArr[0] + "\\" + strSplitedArr[1] + "\\" + strSplitedArr[2];
strMapPath = strMapPath + "\\Plugins";
try
{
string sql = " DELETE FROM wgn_US WHERE [OID] =" + iLastIdInAccess;
OleDbConnection My_Connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strMapPath + @"\MWSWAT\mwswat.mdb;;Persist Security Info=False;");
if (My_Connection.State == ConnectionState.Closed)
{
My_Connection.Open();
}
OleDbCommand My_Command = new OleDbCommand(sql, My_Connection);
My_Command.ExecuteNonQuery();
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
return true;
}
#endregion
No comments:
Post a Comment