Issues with updating Access DataSource  
Author Message
danny _van_der_walt





PostPosted: .NET Framework Data Access and Storage, Issues with updating Access DataSource Top

I have generated an bindingsource and dataset without code.
I have bound data to a text box and navigate easily enough with a navigator object.

When I try to save the data to the mdb file with the following code nothing happens.
No exceptions, No updates.

this.dummyTableBindingSource.EndEdit();
dummyTableTableAdapter1.Update(jobCards_beDataSet.DummyTable);
jobCards_beDataSet.DummyTable.AcceptChanges();

DummyTable consists of
{
DummyNo Autonumber
DummyName Text (not required)
}

The row states do change when the data is modified, added or deleted.
The mdb file is not read only , it does not have a password.

I can also open the mdf file and edit directly on the table.

The main idea behind this app is to use as little code as possible.
I could do a manual update with a custom method but I really want to know if the existing generated binding sources, adapters and datasets can be used.

Regards
Danny



.NET Development35  
 
 
Sarah Parra - MSFT





PostPosted: .NET Framework Data Access and Storage, Issues with updating Access DataSource Top

Hi Danny,

Make sure you are not running into Problem #2 in this FAQ post:

FAQ: My database isn't being updated, but no errors occurred in my application
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=427451&SiteID=1

Since you have already checked the RowStates, that means the Update/Insert/DeleteCommands should be running correctly, and if no exceptions occur, they should be updating the backend as well.

Thanks,
Sarah

Please Mark as Answer if this answers your question, or Unmark as Answer if it is marked and you feel it is not answered.



 
 
danny _van_der_walt





PostPosted: .NET Framework Data Access and Storage, Issues with updating Access DataSource Top

Thanks Sarah

We found something strange. The mdb file is copied to the bin folder, but the data source path remains the same in the solution explorer.
When debugging in the IDE we encounter the problems. But when we click on the project exe in the bin folder it works fine and the data is updated,added and deleted.

Everytime I compile the project, the data in the mdf in the debug folder is overwritten with the data from the mdb file that resides in the solution explorer. The mdb itself does not appear to be copied over as the file date remains the same.

Regards
Danny


Is this an oversight from Microsoft or an undocumented feature to get us away from MDBs


 
 
Sarah Parra - MSFT





PostPosted: .NET Framework Data Access and Storage, Issues with updating Access DataSource Top

I don't think what you are seeing is strange, unless I have misunderstood something. What you are seeing sounds exactly like the default VS behavior as described in the FAQ. The data source path is not supposed to change. You didn't mention what your connection string references for the database path, but I would assume it uses the DataDirectory keyword. That means that when the project is run, it will always use the copy of the database that's in the output folder. In order to make sure there is always a copy there, VS copies it when you run. This is a VS behavior, not ADO.NET or the .NET framework itself. That's why it works when you run outside of the de****, because the app will use the same file it's been using, which is the one in the output folder, but VS will not be there to make the copy before you start running.

You should see the MDB file itself copied. I don't know why the file date would remain the same. It's a simple operation, VS is not going to do any sophisticated data transfer to move the data over without changing the file itself.

Personally, I don't like the default behavior because it's confusing for just the reasons you are seeing, but you can change it by modifying the file properties in the solution as described in the FAQ. It happens with SQL Server Express MDF files too, so it's not a subliminal hint to move away from MDB.

Do you think you are running into something different than what's in the FAQ, or have you tried changing the "Copy to Output Directory" setting and it didn't help

Thanks,
Sarah