简体   繁体   中英

Deploying C# application with SQL database

I have developed a C# application with SQL database, now i want to package it with the database and deploy it on some other machine which does have sql installed. How should i go with it.

What should be the connectionstring for the project, currently i am using "initialcatalog".

Pls Help

I am not sure, if I understand the question well.

  • If this is a C# class library only, you can get the dll and deploy in the required application.

  • If this is a web application, you can either create a web deployment package or publish the site.

For SQL migration, you can used the database publishing wizard from microsoft.

http://www.microsoft.com/en-in/download/details.aspx?id=5498

I hope my answers helped you.

Make .bak file of your SQL database.

Publish c#.NET application.

In the folders where you programmed this application, you will find published setup of your application.

Complete wizard in that publish setup folder.

upload database backup file(.bak) where you want to install application.

In this way you can deploy your application.

there are some install maker tools like install shield, which you can make a setup for your application, About your connection string if your sql server is on your local computer you should set the "DataSource = . " somthing like this : "Data Source=.;Initial Catalog=yourDBName;User ID=sa;Password=1" the dot means local computer.

to create your data base on the target computer you can right click on your database and select task\\generateScript and follow the wizard to make your database script the run that script on the target computer.

It's a common practice to include mdf or sdf file directly in solution (at least that's how are a lot of MS examples like Northwind/AdventureWorks are done). So you need to detach your db and then simply reattach it to other db server. You can read more here http://goo.gl/0FV1N

You can create a set of SQL Scripts to build the database via T-SQL or you could create a script to attach a new database to the server using the MDF/LDF files you include with your project.

Examples:

C# use script to create database

http://support.microsoft.com/kb/307283

Regardless of how you do it, you'll first need to establish a connection to the SQL Server with rights to create a new database. You might want to prompt for these values during install or on the first launch of your program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM