#region Delete if More row exist(1041)
public void DeleteIfMoreRowExist(string strMWPath)
{
try
{
string[] strSplitedArr = strMWPath.Split('\\');
strSplitedArr = strSplitedArr.Where(w => w != strSplitedArr[3]).ToArray();
string strMapPath = strSplitedArr[0] + "\\" + strSplitedArr[1] + "\\" + strSplitedArr[2];
strMapPath = strMapPath + "\\Plugins";
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strMapPath + @"\MWSWAT\mwswat.mdb;;Persist Security Info=False;");
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
string cmdText2 = "SELECT Count(*) FROM wgn_US";
var command2 = new OleDbCommand(cmdText2, myConnection);
var RCount = command2.ExecuteScalar();
if (Convert.ToInt32(RCount) > 1041)
{
string sql = " DELETE FROM wgn_US WHERE [OID] > " + 1041;
OleDbCommand My_Command = new OleDbCommand(sql, myConnection);
My_Command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
}
#endregion
public void DeleteIfMoreRowExist(string strMWPath)
{
try
{
string[] strSplitedArr = strMWPath.Split('\\');
strSplitedArr = strSplitedArr.Where(w => w != strSplitedArr[3]).ToArray();
string strMapPath = strSplitedArr[0] + "\\" + strSplitedArr[1] + "\\" + strSplitedArr[2];
strMapPath = strMapPath + "\\Plugins";
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strMapPath + @"\MWSWAT\mwswat.mdb;;Persist Security Info=False;");
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
string cmdText2 = "SELECT Count(*) FROM wgn_US";
var command2 = new OleDbCommand(cmdText2, myConnection);
var RCount = command2.ExecuteScalar();
if (Convert.ToInt32(RCount) > 1041)
{
string sql = " DELETE FROM wgn_US WHERE [OID] > " + 1041;
OleDbCommand My_Command = new OleDbCommand(sql, myConnection);
My_Command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
LoggerClass.ErrorException(ex.Message, ex);
}
}
#endregion
No comments:
Post a Comment