如何在visual studio 2008中使用数据库创建.exe [英] how to create .exe with database in visual studio 2008

查看:90
本文介绍了如何在visual studio 2008中使用数据库创建.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在vs 2008中创建了一个以sql server 2008为数据库的项目。

现在我要制作一个安装文件(exe),可以安装在任何计算机上。

请帮我如何做同样的事。

Hello all,

I have created a project in vs 2008 with sql server 2008 as database.
Now i want to make a setup file(exe), which can be installed on any computer.
Please help me how to do the same.

推荐答案

USE Visual Studio Windows应用程序安装项目



看看这里:





Visual Studio Windows应用程序设置项目 [ ^ ]
USE Visual Studio Windows Application Setup Project

Take a look here :


Visual Studio Windows Application Setup Project[^]

看这个例子



我们可以实现自动附加数据库只需使用以下连接字符串。



1)将一个名为DB的文件夹添加到项目中,并在分离后将数据库文件复制到其中来自你的sql server。



2)改变你的连接字符串:

look this example

We can implement auto attach database just use the connection string following.

1) Add a folder named "DB" to the project, and copy the database file into it after you detach it from your sql server.

2) Change your connection string like this:
<connectionstrings>
        <add name="WindowsFormsApplication1.Properties.Settings.BabakConnectionString">
            connectionString="Data Source=.;AttachDbFilename=|DataDirectory|\DB\Babak.mdf;
            Initial Catalog=test;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </add></connectionstrings>







3)之后,当您运行应用程序时,数据库文件将自动附加到sql server,并且数据库名称为test,您可以打开sql server management studio查找它。




3) After these, the database file will auto attach to the sql server when you run your application, and the database name is "test", you can open the sql server management studio to find it.


这篇关于如何在visual studio 2008中使用数据库创建.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆