Concurrency Violation Help

G

Guest

I have a dataset that contains 2 datatables. When I change a record and try
the update command it gives me this error...
Concurrency violation: the UpdateCommand affected 0 records. at
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping
tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable)

Here is the code:
SqlConnection con = new SqlConnection(strCon) ;
try
{
con.Open() ;
daAllSigns = new SqlDataAdapter(sqlAllSigns,con) ;

SqlCommandBuilder cb = new SqlCommandBuilder(daAllSigns) ;

daAllSigns.Fill(dsGrids,"AllSigns") ;


daQueSigns = new SqlDataAdapter(QueSigns,con) ;


daQueSigns.Fill(dsGrids,"QueSigns") ;


// Change record
dsGrids.Tables["AllSigns"].Rows[3]["Sign_Brand"] = "TEST BRAND" ;
dsGrids.Tables["AllSigns"].Rows[3]["Sign_SignDesc"] = "TEST DESC" ;

daAllSigns.Update(dsGrids.Tables["AllSigns"]) ;

catch(Exception exc)
{
Debug.WriteLine(exc.Message + " " + exc.StackTrace) ;
}

Does anyone know why this error could be coming up, the code seems pretty
straight forward to me....
 
D

David Sceppa

Bryan,

The code definitely look simple enough. I might be missing something,
but I don't see how the multiple tables in the DataSet could lead to this
problem.

The exception occurs when the server indicates that no rows were
affected by the query the DataAdapter executed. The DataAdapter interprets
this result as an update failure due to a concurrency issue and throws the
concurrency exception.

You'd stand a better chance of getting a helpful response on the
newsgroup if you're able to isolate and reproduce the problem, minimizing
the number of columns and rows involved, and including the initial query
you're using, as well as CREATE TABLE and INSERT INTO queries.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2005 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top