如何使用SQL Server数据库部署或发布Windows应用程序.. [英] How to deploy or publish windows application with SQL server database..

查看:202
本文介绍了如何使用SQL Server数据库部署或发布Windows应用程序..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好先生,

我使用visual studio 2010,c#4.0和sql server 2008创建了一个Windows应用程序。我已经完成了我的项目和测试。现在我想用sql server数据库部署我的项目,以便我的客户端在安装我的软件时,安装向导在本地机器上配置数据库,创建数据库,创建所有必需的表。

所以我不需要安装sql server到我所有的客户端机器..



请帮我解决这个问题...



我尝试过:



public static string connectionname()

{

string ser =Data Source =+ System.Environment.MachineName + @\ SQLEXPRESS; Initial Catalog = database of name; integrated security = true;

return ser;

}

Hello sir,
I made a windows application using visual studio 2010, c# 4.0 and sql server 2008. I have already finished my project and testing. Now i want to deploy my project with sql server database so that my client when install my software, installation wizard configure database on local machine, create database, creates all required tables .
So that i need not to install sql server to all my client machine..

Please help me to solve this problem...

What I have tried:

public static string connectionname()
{
string ser = "Data Source=" + System.Environment.MachineName + @"\SQLEXPRESS; Initial Catalog=name of database; integrated security=true";
return ser;
}

推荐答案

您必须创建一个包含创建数据库代码的SQL查询脚本。使用sql manager express:



0)连接到你的服务器

1)右键单击数据库

2 )在上下文菜单中,选择任务,然后选择生成脚本



它将显示向导表单。只需按照页面进行操作,它最终将生成一个脚本,用于创建数据库,包括所有(选定的)表,存储过程,视图和用户定义的函数等。



获得该脚本后,将其包含在应用程序解决方案中,如果数据库尚不存在,只需从应用程序运行该脚本即可。我将把那部分的确切细节留给你真棒的谷歌能力。



FWIW,我用google搜索c#从sql脚本创建数据库,以及看起来它可能包含在第一个链接中找到的所需信息。
You have to create a sql query script that contains the code to create your database. Using sql manager express:

0) Connect to your server
1) Right click the database
2) In the context menu, select "Tasks" and then "Generate Scripts"

It will present a wizard form. Just follow the pages and it will eventually generate a script that will create your database, including all (selected) tables, stored procedures, views, and user-defined functions, etc.

Once you have that script, include it in your application solution and simply run the script from your app if the database doesn't already exist. I'll leave the exact details of that part to your awesome google abilities.

FWIW, I googled "c# create a database from a sql script", and something that looks like it might contain the desired info was found in the very first link.


这篇关于如何使用SQL Server数据库部署或发布Windows应用程序..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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