Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I'm pulling my hair out on this one. I have a program that access a MDB file using TableAdapter. It was working fine until recently.

I am able to write and read the table but when I try to delete a specific line, it does not work.


MessageBox.Show(dataMDBDataSet.Machines.Count.ToString());
if (machinesBindingSource.AllowEdit)
{
   MessageBox.Show("yes");
 }
dataMDBDataSet.Machines.Rows.RemoveAt(i);
machinesBindingSource.EndEdit();
dataMDBDataSet.AcceptChanges();
machinesTableAdapter.Update(this.dataMDBDataSet.Machines);
MessageBox.Show(dataMDBDataSet.Machines.Count.ToString());
this.machinesTableAdapter.Fill(this.dataMDBDataSet.Machines);
MessageBox.Show(dataMDBDataSet.Machines.Count.ToString());


When I press delete, the count dropped by 1. Allow edit is true. It updates without error. When I fill the table again, the count went back to original!

I tried everything I know. The MDB file is totally fine if I edit it with Microsoft Access 2007. I am using framework 4.0.

Can someone help?
Posted
Comments
cltw666 12-Apr-11 0:37am    
Hello guys,

Thanks for your reply. As mentioned, I'm able to read and write. It is not the link to the MDB. Some of my table do not have primary key. Would that be the reason why it does not work?

It has worked before, I dont understand why it does not now.

I hope that Your Using Primary key once u delete the primary key and try.And while debugging the application please close the msacess database.
 
Share this answer
 
Few options come in mind:
- if (hopefully) you're using transactions, ensure that the transaction gets committed and is not rolled back.
- if the MDB is included into your project, check that you're not using the file from bin/debug (or equivalent) directory. If you use the file from there, it may get overwritten when you compile the project.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900