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 8411387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:24:36+00:00 2026-06-10T00:24:36+00:00

In my C# program I have a big problem: I add an SQL server

  • 0

In my C# program I have a big problem:

I add an SQL server database named “Behgozin_DB” to my project. I do the following steps for adding the database:

  1. In my SQL server management studio I detach my database
  2. In my visual studio from Data menu I add new data source
  3. My Connection String is:

Data Source=(local);AttachDbFilename=|DataDirectory|\DB_Behgozin.mdf;Integrated Security=True

Everything is OK but when I insert something into my database after closing the application , I can not see any data. But when I right click on my tables in my visual studio server explorer menu and choose show table data, my application reads the whole table of data completely!

Another problem is after working with this app, even it can not read its own data in table.

Its a C# project in Visual Studio 2010 SQL Server 2008.

  • 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-06-10T00:24:37+00:00Added an answer on June 10, 2026 at 12:24 am

    Your database file has 2 copies. One is in your project and the other is in bin\debug. In design time you edit the one in your project. Each time your project changes and you build it, the project database file is overwriting the file in bin\debug, and this file you’re updating in run-time.

    In order to solve that you have three options:

    1. Use only the file in bin\debug. Set the project database file copy options to “Never” (in the properties window), show all files of the project and add the bin\debug database file to the server explorer. Caution: If you accidently delete the bin\debug folder all your changes are gone. Manually copy the database file from bin\debug to the project folder when you change it.

    2. Put the file in your sql server folder and not in your project. When deploying, change the connection string and copy the database from server.

    3. Replace “|DataDirectory|” macro with the absolute path to the project database file. When deploying, just change it back to “|DataDirectory|”

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

Sidebar

Related Questions

I have a big problem. My program must save a Xml file with 3
I have a big security problem with my program, and I need to make
Hi, I have a big problem. I'm making a java program and I have
I have a big problem with a program in assembly x86. I have to
I have a big problem for execute my program. we use redis hkey and
I have a big problem with std::wstring memory allocation. The program crash when I
I have a big problem with a java program. I try to implement a
I have a big problem understanding several lines from the following code (numbers marked
Have a big problem here. I can't open any type of project in Visual
Suppose I have a big program that consists of hundreds of methods in it.

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.