Click here to Skip to main content
12,887,768 members (32,615 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 3 Jul 2010

ClickOnce applications using VistaDB

, 5 Jul 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
ClickOnce applications have many benefits including ease of deployment, optional automatic updates and framework requirement checks.The only real complicated issue with ClickOnce is how to deploy the database. I can’t imagine trying to deploy SQL Server as a part of your application!

ClickOnce applications have many benefits including ease of deployment, optional automatic updates and framework requirement checks. The only real complicated issue with ClickOnce is how to deploy the database. I can't imagine trying to deploy SQL Server as a part of your application! VistaDB is a perfect fit to be embedded in a ClickOnce application due to the ease of XCopy deployment. Our 100% managed engine means you don't need any permissions on the client side, no installs or registry permissions are required. VistaDB can also deploy one DLL to either a 32 or 64 bit machine, there is no need to target a specific CPU type in advance of the deployment.

This article explains how to get a simple Windows Forms application (databound using Entity Framework) up and running with VistaDB and ClickOnce deployment. There are a few manual steps, but almost all of these will apply to any client side xcopy deployable database. They obviously do not apply to SQL Server!

Databound WinForms Project

ClickOnce with VistaDB Screenshot

The Windows Forms project used in this example is very simple and consists of the following:

  • A VistaDB 4 Database containing one table named Employees with the columns and data shown in the grid to the right.
  • An ADO.NET Entity Model (EF model) of the VistaDB database, built using the Visual Studio wizards.
  • One Form (shown on the right) that contains a grid and a button that populates the GridView with a simple Linq query against the EF model.

Get Employees Code

private void button_GetEmployees_Click(object sender, EventArgs e)
    VistaDBEntities context = new VistaDBEntities();

    var query = from emps in context.Employees
                select emps;

    gridview_Employees.DataSource = query;

The code above is executed when the Get Employees button is clicked. This is very simple, grab all the employees and put them in the grid.

Application Setup for ClickOnce Deployment

This simple Winform application is not intended to be a showcase product. The point of this article is to explain the process of deploying a data driven application via ClickOnce. There are a few steps needed to ensure that the VistaDB database is included in the download and that it functions properly client side after deployment.

Database Location

The database has been added to the Visual Studio solution, and set to Copy always to the output directory, and the Build Action as Content.

Copy Always options ensures that the database will always be copied to the data directory which is very important to the ClickOnce environment. You can’t rely on a specific path being present on the end users machine, everything needs to be deployed together.

The Build Action needs to be set to Content for the database to show up in the Application Files list. This is important as it allows you to automate the deployment of the database with the application.


Project Publish Options

Within Visual Studio 2010 (C# Winform projects), the Publish tab is a part of the project properties. Right click the name of the project and select properties. Most of the changes needed to make this application ClickOnce can be made in the publish section of the project properties.


Application File Changes

The Application Files section of the Publish properties manages all of the project files that need to be included for deployment. Both the VistaDB4 database and Vistadb4 assembly should be in this list (because we added them to the project and changed the flag to be content, copy local), and need to be set to required in the download group. The application database will also need to be set to Data File under the Publish Status column.


By setting the database to the Data File, the ClickOnce system knows to ensure it is put into a folder that has read and write permissions for the user.

Application Prerequisites

The next changes need to be made to the Prerequisites section of the publish options. This section handles all requirements needed on the client machine to run the application. This portion can vary due to the requirements of your application, but in this case the .NET Framework 3.5 SP1 will be needed to support Entity Framework.

PreRequisites Dialog

Application Updates

The following changes are optional, but can prove to be very handy when it comes to shipping new versions of a product to users. Applications deployed by ClickOnce can be configured to automatically test for a newer version when they run. The user will then be prompted to update automatically.

ClickOnce Application Updates

Publish the Application

After the above changes, you can save the property window and make sure the project still builds. To publish the application, right click the project in Visual Studio and select the Publish option. Follow the steps in the Publish Wizard. After the application is published, you can open it at your specified location. This will mimic the end user experience. You will need to move the files to a public facing server if you want end users to be able to use the application.

Publish Version Settings

On the same Publish tab for the project, you can specify the current Publish Version, and a very handy checkbox to automatically bump this version after each publish. This makes it very easy to push a new version of the application, and not have to remember to rev the version in the AssemblyInfo.

View the Click Once Sample Now!

VistaDB ClickOnce Application Install Screenshot

We have published this sample as a ClickOnce in our tutorial area of the VistaDB main site. This is the default publish page. You can customize this if you want, but we left it at the default so you can see what the normal experience looks like after publication of the application.

VistaDB Clickonce Sample – Go to the site now and install the sample for yourself. A start menu shortcut will also be created.

We didn’t sign this package with our code signing certificate, so you will see a security warning dialog when you run the application.

Launch the application, and click the GetEmployees button to see the data from the database. There will be a start menu item, and a desktop shortcut. Each time you run the application, it will go to our site and look for a newer version. If one is present, it will prompt you to download it.


ClickOnce is a new and exciting way to deploy software to end users. It allows for an online model to the application, but with offline capabilities (the user does not have to be on the Internet to use the application).

Companies currently shipping desktop applications should to take a look at ClickOnce, it can be a great way to quickly deploy updates to applications with very little work.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
I hold a PhD in computer science, and have been a practicing developer since the early 90's.

I used to be the owner for VistaDB, but sold the product to another company in August 2010.

I have recently moved to Redmond and now work for Microsoft. Any posts or articles are purely my own opinions, and not the opinions of my employer.

You may also be interested in...


Comments and Discussions

QuestionVistaDB on a network share accessible by multiple concurrent users? Pin
Uldis Rāts27-Nov-13 6:27
memberUldis Rāts27-Nov-13 6:27 
GeneralVistaDB Pin
westville_mike9-Dec-10 2:21
memberwestville_mike9-Dec-10 2:21 
GeneralRe: VistaDB Pin
JasonShort9-Dec-10 10:47
memberJasonShort9-Dec-10 10:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 5 Jul 2010
Article Copyright 2010 by JasonShort
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid