S
sherifffruitfly
Hi,
I'm deleting a bunch of records from my DB, and they actually DO get
deleted (as I verify by looking afterwards). But then I get the
exception in the subject line. Isn't it weird that all of the correct
records would get deleted, and only *after* that, an error gets thrown?
Here's the code I'm using - thanks for any ideas!
And yes, I know the method used to avoid the concurrency exception is
ghetto in the extreme. That's why I'm asking for help
cdj
try
{
string oracleTable = "myTable";
string oracleSelectString = "select *
from " + oracleTable + "
where as_of_date between '" + oracleStart + "' and '" + oracleEnd + "'"
;
OracleDataAdapter daAdapter = new
OracleDataAdapter(oracleSelectString, dc_UAT);
OracleCommandBuilder cbCommandBldr =
new
OracleCommandBuilder(daAdapter);
OracleCommand oc = new OracleCommand();
oc.CommandText = "delete from " +
oracleTable + " where as_of_date
between '" + oracleStart + "' and '" + oracleEnd + "'" ;
oc.Connection = dc_UAT;
daAdapter.DeleteCommand = oc;
DataSet data = new DataSet();
data.Tables.Add("tbl");
daAdapter.Fill(data, "tbl");
int numRows =
data.Tables["tbl"].Rows.Count;
//Clear the rows
foreach (DataRow dr in
data.Tables["tbl"].Rows)
{
dr.Delete();
}
//Send back to db
daAdapter.Update(data, "tbl");
MessageBox.Show(numRows.ToString() + "
records successfully
deleted.", "Rates Aggregator");
}
catch (Exception ex)
{
if (ex.Message.StartsWith("Conc"))
{
MessageBox.Show("Records
successfully deleted.", "Rates
Aggregator");
}
else
{
MessageBox.Show("Error deleting
from Rates_test:\n" + ex.Message,
"Delete Error");
}
}
I'm deleting a bunch of records from my DB, and they actually DO get
deleted (as I verify by looking afterwards). But then I get the
exception in the subject line. Isn't it weird that all of the correct
records would get deleted, and only *after* that, an error gets thrown?
Here's the code I'm using - thanks for any ideas!
And yes, I know the method used to avoid the concurrency exception is
ghetto in the extreme. That's why I'm asking for help
cdj
try
{
string oracleTable = "myTable";
string oracleSelectString = "select *
from " + oracleTable + "
where as_of_date between '" + oracleStart + "' and '" + oracleEnd + "'"
;
OracleDataAdapter daAdapter = new
OracleDataAdapter(oracleSelectString, dc_UAT);
OracleCommandBuilder cbCommandBldr =
new
OracleCommandBuilder(daAdapter);
OracleCommand oc = new OracleCommand();
oc.CommandText = "delete from " +
oracleTable + " where as_of_date
between '" + oracleStart + "' and '" + oracleEnd + "'" ;
oc.Connection = dc_UAT;
daAdapter.DeleteCommand = oc;
DataSet data = new DataSet();
data.Tables.Add("tbl");
daAdapter.Fill(data, "tbl");
int numRows =
data.Tables["tbl"].Rows.Count;
//Clear the rows
foreach (DataRow dr in
data.Tables["tbl"].Rows)
{
dr.Delete();
}
//Send back to db
daAdapter.Update(data, "tbl");
MessageBox.Show(numRows.ToString() + "
records successfully
deleted.", "Rates Aggregator");
}
catch (Exception ex)
{
if (ex.Message.StartsWith("Conc"))
{
MessageBox.Show("Records
successfully deleted.", "Rates
Aggregator");
}
else
{
MessageBox.Show("Error deleting
from Rates_test:\n" + ex.Message,
"Delete Error");
}
}