Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
88 views
in Technique[技术] by (71.8m points)

c# - How to deploy application with sql server database on clients

I have designed an accounts software for my clients. I used SQL Server 2008 database with Stored Procedures. It is developed in Visual Studio 2010, .NET Framework 3.0. I have more than 500 clients using Windows 7.

The major problem is:

Is SQL Server runtime automatically installed with .NET Framework? As MS Access database does not required Office to be installed on client.

I can not installed SQL Server 2008 on each client, it is a tough job. Also the clients are not having a good knowledge of installation process.

How to run SQL Server database on clients without installing its setup on clients? Is there any runtime files or setup?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Option 1 - Setup Project

Using Visual Studio you can create a setup project and install prerequisites that you need during installation.

The installation process is very simple and the end user can install application and prerequisites after clicking next buttons.

Here are the steps for Creating a Setup Project:

1- Create a c# Windows Forms Application

  1. Create a C# Windows Forms Project
  2. Add New Item and Add SQL Server Database to your application
  3. Add a table to your application and fill some data in it
  4. Show the data in your main form.

2- Create a Setup Project

  1. Add new project → setup and deployment → setup project
  2. Right Click on Setup project and Add project Output and select primary output from your main project
  3. Right Click on Setup project and Add project Output and select content files from your main project
  4. Right CLick on setup project and Click Properties and click Prerequisites and select SQL Server Express
  5. Select .Net Framework
  6. Select Windows Installer
  7. Select radio button Download prerequisites from the same location as my application.
  8. Right Click on Users Desktop at left pane and add new Shortcut and select application folder, primary output from SampleApplication, and click ok and the rename the short cut to what you need.
  9. Rebuild solution.
  10. Rebuild Setup Project
  11. Go to Output directory of setup project and run setup.exe

It's that easy.

For more information take a look at following docs articles:

  1. How to: Create or Add a Setup Project
  2. How to: Install Prerequisites in Windows Installer Deployment
  3. Walkthrough: Using a Custom Action to Create a Database at Installation

Option 2 - ClickOnce

Using Visual Studio another option is using ClickOnce publishing.

To do so, in properties of your project, in publish tab, click prerequisites button, you can select SQL Express in prerequisites. This way, you only need to set your database files to copy in output directory, and use AttachDbFileName in connection string: Data Source=.SQLEXPRESS; AttachDbFilename=|DataDirectory|Database.mdf; Initial Catalog=Master".
For more information take a look at the following docs article:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...