Posted on 2004-08-22
Last Modified: 2012-05-05
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.DBConcurrencyException.

  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,"table"); and i get the same exception.  When I do this it gives me additional information:  Concurrency violation: the DeleteCommand affected 0 records.
Question by:johnduff
  • 3
  • 2

Author Comment

ID: 11867135
Alright, I got the delete to work...the command builder gives you a System.Data.DBDate, changed that to just Date and it I'm habing problem adding something new to the table, I think it is a similar issue.  FYI  i have two date fields that I'm using for the what i'm putting into the db is a DateTime object...hope someone can help

Expert Comment

ID: 11886068
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).


Author Comment

ID: 11888081
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.OleDbCommand c = new System.Data.OleDb.OleDbCommand("INSERT 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);
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline


Expert Comment

ID: 11889788
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.

Author Comment

ID: 11893779
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.

Accepted Solution

DarthMod earned 0 total points
ID: 12142501
Submitted to PAQ with points refunded (100)

Community Support Moderator

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now