By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,594 Members | 3,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,594 IT Pros & Developers. It's quick & easy.

What's causing ADO error: "Concurrency violation: the DeleteCommand affected 0 records"

P: n/a
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!

try
{
string oracleTable = "cmr_admin.tbl_market_intrates_test";
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");
}
}

Oct 31 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.