Writing to SQL Server 2005 Express Edition not saving from C# App

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

I'm new to C#, so this really easy to answer for anyone that is adept at
this...

I'm having trouble saving data from my text boxes on a user form to my SQL
database. Everything works fine while in debug mode, the data is saved and
reflcted like it shoul be, but once I exit debug mode, all the changes are
lost when I reopen the app in debug mode again?

I saw the answer to this problem in a video but cannot find the video again?
I tried changing some properties of the database files but can't seem to
find the right file to change to mak it work. I believe I need to change a
property to either "Save Always" or "Save if Newer" if that turns on any
lightbulbs for anyone? I think this is only a problem for me while running
the app in debug mode (the video said). I believe if I delivered this app to
someone else as an .exe, it would work fine (thats what the video was saying
when they explained which file I needed to change to "copy always" or "copy
if newer").

Thank You,
Matt
 
Matt said:
I'm new to C#, so this really easy to answer for anyone that is adept at
this...

I'm having trouble saving data from my text boxes on a user form to my SQL
database. Everything works fine while in debug mode, the data is saved and
reflcted like it shoul be, but once I exit debug mode, all the changes are
lost when I reopen the app in debug mode again?

I saw the answer to this problem in a video but cannot find the video
again? I tried changing some properties of the database files but can't
seem to find the right file to change to mak it work. I believe I need to
change a property to either "Save Always" or "Save if Newer" if that turns
on any lightbulbs for anyone? I think this is only a problem for me while
running the app in debug mode (the video said). I believe if I delivered
this app to someone else as an .exe, it would work fine (thats what the
video was saying when they explained which file I needed to change to
"copy always" or "copy if newer").

If you are using Sql Server Express in "User-Instance" mode with the
Visual Studio default configuration, then every time that you run your
project in Debug mode Visual Studio copies the .mdf that contains the
database in your project directory into the build directory. The program
then uses that copy and it writes correctly. But if you then run it again,
it gets overwritten with the copy in the project folder, so you lose your
changes.
Change the properties of the .mdf file and set it to "Copy if newer" if
you want the database to only be overwritten when you make changes to its
design.
 
Thank you for the explanation, it sucks being new to a language, a
development environment, a database system, etc! I hope the learning curve
goes a bit faster as time goes on...

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top