CommandBuilder's have very limited ability to deal with Concurrency and
essentially, if you look at what they generate, you'll see that basically
everything has to match. I'd advise doing a debug.WriteLine on the
SelectCommand, Update Command etc for the commandbuilder so you can see what
it's actually generating. Also, just as an FYI, remember that the
CommandBuilder creates the other commands by virtue of the select statement,
so you have to make sure that your key fields for instance are contained in
the select query. Bill Vaughn has a great article on it at
www.betav.com ->Articles- > MSDN , Weaning Developers from the
commandbuilder.
Anyway, if the Adapter the commandbuilder is helping sees a rowstate as
Modified for instance, and then can't find a row to match one the update,
then it will throw a Concurrency Exception assuming that its been modified
even though it hasn't. So I'm guessing that something is happening in
your SELECT statement that may be causing this. I believe it generates a
different exception if the problem is lack of a primary key (something like
Update Command must use Updateable query or something like that) so that's
probably not it.
Like I said though, since the CB uses the SELECT command to generate its
logic, you need to start there (assuming you are positive that nothing else
is modiying the data) and then verify the update/insert/delete commands it's
using.
HTH,
Bill
--
W.G. Ryan, eMVP
http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
Andrea Grandi said:
Hello
I've this code:
Dim cmdNoleggi As New SqlCommand
cmdNoleggi.Connection = _conn
cmdNoleggi.CommandText = strSQLNoleggi
Dim daNoleggi As New SqlDataAdapter(cmdNoleggi)
Dim cbNoleggi As New SqlCommandBuilder(daNoleggi)
'I do all the modifies to my DataSet, then......
'.....
'Finally:
daNoleggi.Update(_ds.GH_Noleggi)
At this point I get a Concurrency Violation error. The fact is that no
other peple are modifying this data, so why does it give me errors?