johnduff
asked on
System.Data.DBConcurrencyException
I am accessing an access database with a couple tables in it, i created data adapters for all the tables and i made one dataset with all the tables in it, probably not the best, but it works. I have a 1-many relationship with my employees and available tables. when i change the available table then call the
Update(dataset, "tablename") method I get a System.Data.DBConcurrencyE xception.
I thought maybe I was passing bad data, so i just tried deleting a row from the table...
dataset.tables["available" ].Rows[0]. Delete(); then called the update...
Adapter.Update(dataset,"ta ble"); and i get the same exception. When I do this it gives me additional information: Concurrency violation: the DeleteCommand affected 0 records.
Update(dataset, "tablename") method I get a System.Data.DBConcurrencyE
I thought maybe I was passing bad data, so i just tried deleting a row from the table...
dataset.tables["available"
Adapter.Update(dataset,"ta
Are you using IDENTITY columns? - They had caused similar problems for me, when I was using an event (DataChanged) to ready the last value of the Identify for an Insert.
Also remember Access locks the whole table when you start updating, so you cannot have multiple connections on this. You might want to consider switching to MSDE (or SQL Server lite).
Also remember Access locks the whole table when you start updating, so you cannot have multiple connections on this. You might want to consider switching to MSDE (or SQL Server lite).
ASKER
I'm not using identity columns, i don't think, i'm not sure what those are. I'm only opening the connection once, so i don't have that other problem either. I tried doing my own oleDBCommand Insert command and it dosn't work either, this is what i have:
System.Data.OleDb.OleDbCom mand c = new System.Data.OleDb.OleDbCom mand("INSE RT INTO [GeneralAvailTimeSlot] (Day, EmployeeID, TimeFrom, TimeTo) VALUES ("+ 5 +",44222,"+ new DateTime(2000,5,5,7,0,0) +"," + new DateTime(2000,5,5,13,0,0)+ ")", this.oleDbConnection1);
this.oleDbConnection1.Open ();
c.ExecuteNonQuery();
System.Data.OleDb.OleDbCom
this.oleDbConnection1.Open
c.ExecuteNonQuery();
The problem might be related to the Date field in your table. Have you tried a similar test but after having removed the Date fields from the table?
It seems Access truncates the Time information in the DATE/TIME field, leaving only the DATE.
This google thread might explain it too.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=eOeCLQVMDHA.2768%40tk2msftngp13.phx.gbl&rnum=1&prev=/groups%3Fq%3D%2522Access%2520Database%2520Updates%2522%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
It seems Access truncates the Time information in the DATE/TIME field, leaving only the DATE.
This google thread might explain it too.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=eOeCLQVMDHA.2768%40tk2msftngp13.phx.gbl&rnum=1&prev=/groups%3Fq%3D%2522Access%2520Database%2520Updates%2522%26hl%3Den%26lr%3D%26ie%3DUTF-8%26sa%3DN%26tab%3Dwg
ASKER
I think I solved this on my own, when I want up to where the command builder created the Insert and Update commands i just put [] around the column names and now it works, I think Day is a reserved word in access and that was one of my columns.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER