fwan
fwan

Reputation: 193

Ensure two computers running the same version of the application

Here's my situation. I have a desktop application that interacts with sql server. There will be one sql server and multiple applications will access the same database. Currently two computers are running the same application.

If I make a change in database schema, I will also have to make a change in the application and now the problem occurs.

Before change: Table Invoice with columns - title varchar(128)

After change: Table Invoice with columns - title varchar(128) - content varchar(128)

Computer A uses the old application that does not have any information about that new column "content" and Computer B uses the new application.

Because A is using the old app, it will insert null values to the table and B will face null pointer exception.

I cannot think of any other way since the old app cannot just terminate and download the newest version in the middle of a transaction. And I don't think it's a great idea to be like tell people don't use the app within downtime and restart the app after.

How does a website handle this? I think all of the websites will face this issue.

What is the proper way to prevent this to happen? Please point me to the right direction

Upvotes: 3

Views: 84

Answers (3)

Reza Aghaei
Reza Aghaei

Reputation: 125247

There are some options to do it. For example:

Using ClickOnce deployment, you can specify a minimum required version for the application in the Application Updates dialog box. You can also check it programmatically using code while the application is running.

Also if you don't use ClickOnce, you can keep the minimum required version of your software in database and the at start of your application check the version from database and if the current version is less that minimum required version, then don't run the application. Also you can check it programmatically while the application is running if you need.

var version = Assembly.GetExecutingAssembly().GetName().Version;

Upvotes: 1

dimitrog
dimitrog

Reputation: 1

A quick and dirty solution would be to write a trigger for insert that would write a default value to the new column ("content). Alternatively (easier) use a default value for your column.

Upvotes: 0

SSS
SSS

Reputation: 5403

You can query a record in the database that tells you what is the minimum version of the app that is compatible.

Upvotes: 0

Related Questions