0

I have attached database on my project as I wanted this to be deployed so I used the connection string

Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Inventory_System.mdf;Integrated Security=True;Connect Timeout=30

I have saved some data in the database but when the app is restarted, the data is gone on the data grid view, not only that the data preview on the dataset is empty too.

I already changed the database property Copy to Output Directory to "Do not copy" so it won't be re written every build and run, but nothing's changed any ideas what went wrong?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Did you check if the MDF in the folder bin\debug (or bin\release) contains your data using an external tool (SSMS or else)? – Steve Dec 25 '21 at 18:15
  • 1
    Your database is getting a temporary copy every time you run it. Instead, attach your database normally using `CREATE DATABASE ... FOR ATTACH`, do *not* use `AttachDbFilename` which is deprecated – Charlieface Dec 25 '21 at 18:16
  • @Steve yes i checked that there are some data that is saved into the database, but still wondering why those data are not showing when selected on the data preview – Melvin Esguerra Dec 26 '21 at 06:14

0 Answers0