views:

110

answers:

3

I'm developing a simple database app in visual studio (c# for Windows) using an access backend.

That's all fine until I try to open the database file from within access, when all the reocords get deleted.

Could anyone explain why this is please?

A: 

We need more information. You say that when you open the database from within access, "all the records get deleted". The way the question is phrased implies that some process is running as part of opening the database, e.g., an autoexecute macro. Do you really know that is what is happening? Or are you really just saying that "when I open the database file from access, the records are not there". If the latter, then something is happening along the lines of what cletus suggests.

Rob3C
+1  A: 

Did you add the database to your solution? Select it and check the Copy Local (aka Copy to Output Directory) setting in the Properties window. Make sure it isn't set to Copy Always,

Hans Passant
+1; Yep, this has bitten me before. Certainly good advice, even if it doesn't turn out to be the OP's problem.
echo
A: 

This is an old question and I don't know if the original poster is still around, but something that didn't occur to me at the time I originally read the question was that perhaps the C# app is using a transaction to insert the data and is not committing it. If that were the case, the data would be visible in the C# app and would not be there when you opened the file in Access. On the other hand, the data wouldn't be there in a new session of the C# app, either, so this might not be the issue.

David-W-Fenton