日期:2014-05-17 浏览次数:20819 次
public void DataBaseDelete(string FieldName, string FieldValue, string DataTableName)
{
if (this.OleDbCommandString != null && this.ConnectionString != null)
{
MyConnection = new OleDbConnection(_ConnectionString);
MyDataAdapter = new OleDbDataAdapter(_OleDbCommandString, MyConnection);
MyDataSet = new DataSet();
MyDataAdapter.Fill(MyDataSet, DataTableName);
MyDataTable = MyDataSet.Tables[DataTableName];
DataRow[] Dr = MyDataTable.Select(FieldName + "=" + FieldValue);
if (Dr.Length > 0)
{
foreach (DataRow Dr1 in Dr)
{
MyDataTable.Rows.Remove(Dr1);
}
}
try
{
MyDataAdapter.Update(MyDataSet, DataTableName);
}
catch (Exception Err)
{
MessageBox.Show(Err.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else