Solved

Using Local Database sdf in C#

Posted on 2008-06-19
3
7,600 Views
Last Modified: 2013-12-16
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
Comment
Question by:wooderz
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 21821216
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
 

Author Comment

by:wooderz
ID: 21821260
Yes you are right, this is what was happening. Bit rubbish if you ask me!
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 21821302
I agree. I discovered that behavior the hard way!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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