user1804465
user1804465

Reputation: 13

How do I publish/update a winforms project and not drop tables in the database

I have a winforms project with a mssql database that stores user created data, All created in Visual Studio C# 2010. I am able to publish the project and deploy with clickonce on my local machine. The application updates automatically and works great. when i install the newer version it drops all table data in the database. I currently don't have any data in the database that deploys when i publish, but would like to if needed in the future.

Is there a way to change this behavior in visual studio? if not how do i go about stopping the database from dropping all the users data on update?

I asked this question previously, However users thought it was non constructive. One user stated "this looks more like an issue with the setup that just overwrites the database and has nothing to do with C# or Visual Studio"

Can somebody possibly elaborate on what this user meant by SETUP?

I think this would be a very constructive question as this is a pretty important part of automatically updating a winforms application. I have searched but cannot seem to use the right words for this problem. If this isn't constructive or relevant to this site, Can somebody at least point me in the right direction?

Upvotes: 1

Views: 1421

Answers (1)

kurasa
kurasa

Reputation: 5323

I think the user previously was right. If I am understanding your problem correctly then it has more to do with versioning and deployment strategy than VS or C#.

You could build functionality into your app to check the version of the app on load and whether a database already exists and then make a decision on what to do from there.

A solution could be to deploy with SQL scripts that update the database based on what version you are deploying or if the database exists previously rather than simply overwrite it

possible answer

deployment strategy

another deployment strategy esp Strategy #3 - use re-runnable scripts

EDIT I think your problem has very little to do with whether you're deploying using debug or release

Upvotes: 1

Related Questions