Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7645
  • Last Modified:

Using Local Database sdf in C#

Hi Experts,

In my C# application I have created a database (Store.sdf) and then a Strongly Typed DataSet (Store.xsd). Everything is set up correctly and I can read information from the database, however when trying to insert data, using a number of methods. No data is ever inserted?

Any clues?
Insert Code
 
UsersAdapter.Insert(Username, Password)
 
// Nothing gets inserted?

Open in new window

0
wooderz
Asked:
wooderz
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Are you sure that nothing gets inserted or are you just looking at the wrong file?

Let me explain. Your Store.sdf file is surely at the root of your project. When you run the application, a copy of that file is copied to the bin folder and that's where the data is being updated. If you open the file at the root of your project to look at the data it contains, you won't see inserts/updates/deletes. Also, because you have opened the data file to view it, it will replace the copy in your bin folder because your root file is now "newer" then the bin file. You can change this last behavior by selecting the sdf file, going to its properties, and change the "copy to output directory" property to something else then "copy if newer".
0
 
wooderzAuthor Commented:
Yes you are right, this is what was happening. Bit rubbish if you ask me!
0
 
Éric MoreauSenior .Net ConsultantCommented:
I agree. I discovered that behavior the hard way!
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now