Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:25:57+00:00 2026-05-25T13:25:57+00:00

I have searched a lot regarding my problem but no solution so i am

  • 0

I have searched a lot regarding my problem but no solution so i am posting here to get advise from the experts.

I am making a windows form application , and using Sql compact database.

My Problem :

When i am inserting records in the database using code (run time) they are inserted deleted , update and i can see them updated,inserted,deleted in my application , but when i close the application and start again only a few times they are changed, once a million :). Else i again see blank database ,or if i directly put values in the database from the solution explorer Visual studio 2010 , they stay there forever. I am using simple update,insert ,delete statement but not sure why the changes made to database disappear when i close the application.

First this For all :

   Dim con As New SqlCeConnection
   Dim command As New SqlCeCommand

   connectionString = "Data Source=SqlCompactDatabase/RestaurantDatabase.sdf"
    con.ConnectionString = connectionString

    command.Connection = con
    con.Open()

My Insert Code :

            command.CommandText = "Insert into Inventory(itemcode,itemmin,itemmax,itemdesc) Values('" + itmcod + "','" + min + "','" + max + "','" + desc + "')"
            command.ExecuteScalar()

My Update Code:

    command.CommandText = "update Inventory set itemMin='" + min + "',itemMax='" + max + "',instock='" + stock + "',itemDesc='" + desc + "' where itemcode='" + TextBox1.Text + "'"
    command.ExecuteScalar()

My Delete Code:

      command.CommandText = "delete from inventory where itemcode='" + TextBox1.Text + "'"
    command.ExecuteScalar()

I open close connection correctly there is no error, there is something i can’t figure out 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:25:58+00:00Added an answer on May 25, 2026 at 1:25 pm

    If you added you SQLCE database to your project in Visual Studio, then look at its properties (select the file in the Solution Explorer and look to the Properties panel). Normally a database file has Build Action set to “Content” and Copy To Output option set to “Copy Always”. This means, that every time you build your solution your database from Visual Studio project (most likely the empty one) is copied anew to your build folder ($projectname$\bin\Debug or \Release) and overwrites your existing database with the data added at runtime.

    To solve this problem just set Copy To Output to “If newer” and it will overwrite your data as long as your design-database file changes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a lot to find a solution for my problem, but I
I have searched a lot but i did not get any solution. I want
I have searched a lot but not able to find particular solution. There are
I have searched lot about AdventureWorks2008R2 database, but couldn't get proper URL. Can anybody
I have searched a lot about the difference between Website and WebApplication but didn't
I have searched/Googled around but I'm struggling with the following problem. I am building
I have searched a lot of places but couldnt find a clean sequential explanation
I have searched many questions regarding session_destroy and the often response from the answerers
I have searched a lot about this topic and I can't get this code
i have searched a lot but could not find the exact way to do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.