本文介绍了如何使用SQL Server 2008 R2创建安装应用程序窗体C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要部署SQL Server 2008 R2 Express Edition数据库和表,并使用安装程序项目通过Visual Studio 2010项目以我的应用程序窗体C#进行存储过程.

我创建了项目的设置,但在另一台计算机上安装时却出现错误消息
 
我的脚步
1-在我的项目根目录中创建新文件夹并粘贴数据库文件,并将此连接字符串写入app.config文件中
添加名称="conncet"
        connectionString =数据源= PROBLEMSOLVER \ SQLEXPRESS; AttachDbFilename = | DataDirectory | \ database \ pro_date.mdf;初始目录=测试;集成安全性= True;连接超时= 30;用户实例= True",
        providerName ="System.Data.SqlClient";
2-去解决我的项目,添加新项目并选择设置项目
请帮助我.............逐步使用sql server部署我的项目
我在等待答案

 I need to deploy an SQL Server 2008 R2 Express Edition database and tables,store-procedure with my app form C# by Visual Studio 2010 project using setup project.

i create setup of my project but get me error when instal on another machine  
 
my steps
1- create new folder in my project root and paste database files and write in app.config file this connection string
add name="conncet"
         connectionString="Data Source=PROBLEMSOLVER\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database\pro_date.mdf;Initial Catalog=test;Integrated Security=True;Connect Timeout=30;User Instance=True"
         providerName="System.Data.SqlClient"
2- go to solution my project and  add new project and select setup project
please help me............. step by step deploy my project with sql server
i waiting answer

推荐答案

首先:您没有给出所得到的错误,因此我们所能做的就是重新开始并进行猜测.

first of all: You didn't give the error you get so all we can do is start and guess around.

a)您确定连接字符串正确吗?还是您从系统中以1:1取了它?因此,它引用了PROBLEMSOLVER \ SQLEXPRESS,这意味着您完全给出了系统名称和使用的实例. (因此,在我们的设置中,管理员必须 给我们连接字符串)如果要在本地强制执行(如果我在系统上手动安装SQL Server Express并告诉安装程序使用默认实例,该操作将失败),您至少可以摆脱计算机名.所以你可以提供一些东西 就像.\ SQLEXPRESS.

a) Are you sure that the connection string is correct? Or did you take it 1:1 from your system? So it references PROBLEMSOLVER\SQLEXPRESS which means that you completly gave the name of the system and the instance used. (So in our setups, the admin has to give us the connection string) If you want to enforce it locally (which will fail if I install SQL Server Express on my system manually and tell the setup to use the default instance!) you could at least get rid of the computer name. So you could provide something like .\SQLEXPRESS.

b)您将数据库文件放置在与应用程序相同的目录中?通常将应用程序放在程序文件文件夹中,只有管理员才能拥有该权限.因此,采用这种设计,您的应用程序将仅在管理 权利!您可能希望将其移至更好的目录,例如应用程序数据目录.

b) You placed the database file in the same directory as the application? The application is normaly placed inside the program files folder where only administrators will have rights. So with such an design your application will only run with administrative rights! You might want to move that to a better directory e.g. the application data directory.

但是我会完全更改它.我们将数据库的安装和应用程序分开.这是一种正常的模式,即安装了应用程序但未安装数据库(因为它位于单独的服务器上或来自备份).简单的SQL Server 需要管理员的注意.它可以自动化,但我只提供指向SQL Server的链接(因此用户可以决定要使用哪个版本以及要在哪个系统上启动和运行它!).我会使用 SSDT.但这只是我个人的看法.如果您真的构建了最终用户应用程序,我会检查SQL Server CE是否已经足够消除对SQL Server的依赖.

But I would change it completly. We divided the installation of the database and the application. It is a normal pattern that the application is installed but not the database (because it is on a seperate server or comes from a backup). An SQL Server simply requires attention of an administrator. It can be automated but I would simply provide  a link to SQL Server (So the user can decide what edition he want to use and on which system he wants it up and running!). And I would deploy a database using the SSDT. But that is my personal view only. If you really build an end user application I would have checked if SQL Server CE is already enough to eliminate the dependency to SQL Server.

只是我对这个问题的想法.

Just my thought on this issue.

以诚挚的问候,

Konrad


这篇关于如何使用SQL Server 2008 R2创建安装应用程序窗体C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 18:58