如何将MSSQL数据库与.NET Windows应用程序中的设置绑定

问题描述:


我已经使用.net Windows应用程序创建了一个应用程序.现在该进行设置了.我对如何将项目数据库与安装程序绑定在一起感到困惑,以便何时将其安装在客户端系统中无需手动放置数据库.在开发过程中,我已经使用SQL Server Management Studio工具从外部创建了数据库,请给我一个解决方案.
谢谢

Hi,
I have created one application using .net windows application.Now it is the time to make the setup.I am getting confused about how to bind my project database along with my setup so that when i will install it in the client''s system every there no need to place the database manually. During the development i have created the database externally i.e. using sql server management studio tool.Please give me a solution.
Thanks



试试这篇文章:

部署您的应用程序和数据库 [ http://idpkshr.wordpress.com/2012/03/13/how-to-create-an-installer-for-a-winform-application-using-setup-project/ [
Hi,

Try this article:

Deploy your Application and Database[^]

Article for creating setup of a Windows application:

http://idpkshr.wordpress.com/2012/03/13/how-to-create-an-installer-for-a-winform-application-using-setup-project/[^]


你好

您要记住两件事.
1.我们知道sql server的数据库只有在Management Studio中连接后才能工作.
因此,在您的连接字符串中,您必须为其传递一个值,例如:
AttachDBFileName = Application.StartupPath +"\\ DatabaseName.mdf";

2.在使用设置向导创建设置的过程中,系统要求您添加任何文件,这时您必须选择放置在系统中的数据库文件,也可以选择或添加其他所需的文件.

完成设置后,每次您都将发现数据库将自动复制到安装应用程序的文件夹中,并且在您第一次运行它时,它将自动连接到SQL Server.


希望对您有所帮助.
Hello

Two things you have to keep in mind.
1. As we know database of sql server will work only when it is connected in management studio.
so in your connection string you have to pass a value for it like :
AttachDBFileName=Application.StartupPath+"\\DatabaseName.mdf";

2. While Creating a setup using set up wizard you are asked to add any files , at this time you have to select your database file placed in your system also you can choose or add other needed files at this time.

After Completing the setup, every time you will find that your database will automatically be copied in the folder where your application is installed and as you run it first time it will automatically be connected to SQL Server.


I hope this will help you.