SQL Server Express应用程序帮助 [英] SQL Server Express application help

查看:82
本文介绍了SQL Server Express应用程序帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我将连接字符串用作
数据源=.\ SQLEXPRESS;初始目录= dbTestSharing;集成安全性= True

在开发计算机上,它可以正常工作.但是,当我进行设置(使用Visual Studio)并安装在家用计算机上时,它说

无法连接登录请求的数据库dbMyTest,登录失败.
用户p4 \ admin登录失败"

我的问题是:
1)我没有包括要设置的数据库.我需要这样做吗?
2)当SQL Server运行我的应用程序时,我的用户是否需要制作服务器和实例?
我安装了另一个基于SQL Server Express的应用程序,该应用程序没有这样的功能.

请进行指导.

Hi,
I used my connection string as
Data Source=.\SQLEXPRESS;Initial Catalog=dbTestSharing;Integrated Security=True

On development computer it works fine. But when I made setup (using Visual Studio) and installed on my home computer, it says

"Can not connect the database dbMyTest requested by the login, the login failed.
Login failed for user p4\admin"

My questions are:
1) I did not include the database to setup. Do I need to do so?
2) Does my user need to make servers and instances when SQL Server to run my application?
I installed another application based on SQL Server Express, that did not have anything like that.

Please guide.

推荐答案

如果在应用程序中使用SQL,则无论您在其上运行应用程序的PC是什么,都需要访问SQL Server实例(无论是表达形式还是其他形式)其中包含您的数据库才能正常工作.安装程序的一部分应该是识别该实例,并通过创建实例来确保它包含您的数据库.但是,您的安装绝不要尝试安装SQL Server-必须由用户决定. (我将原因放在了最下面)

确定服务器后,通常将连接字符串保存在应用程序配置文件中,这样就不必为要在其上运行程序的每台PC修改程序.如果您将SQL Server用作单个用户数据库,则可以很容易地将您的应用转换为使用独立的数据库,例如SQLCE(除了.NET和实际的数据库文件外,不需要安装)或SQLLite,它需要更多内容.安装工作量,但不多.


您不应在安装中包括SQL Server.有两个原因:
0)您只能出于版权原因分发SQL Server Express-不能分发SQL Server完整版.
1)他们可能已经在网络上安装了SQL Server.如果是这样,那么他们大概会想使用该版本.
2)如果他们确实安装了SQL Server,并且您开始激增SQL Server Express实例,那么您将烦恼数据库管理员...
3)与在用户控制下的多个分散版本相比,备份SQl Server的单个站点的可能性要大得多.
4)对于普通"用户来说,安装和管理Sql Server非常复杂-这不是一个好主意!
5)它将破坏使用SqlServer而不是SqlCE或SQLite的主要优势-多用户访问.如果每个人都安装了自己的SQL Server副本,那么您将拥有数据库的多个副本,每个副本都由一个人使用.这会引起一些混乱,并且(取决于您编写原始数据库的方式)可能会花费一些精力才能在遇到问题时将其合并到单个实例中.
If you use SQL in your application, then whatever PC you run your application on will need access to an instance of SQL Server (express or otherwise) which contains your database in order to work. Part of your installation program should be to identify that instance and ensure it contains your database by creating it if it doesn''t. However, your installation should never attempt to install SQL Server - that has to be up to the user. (I''ve put the reasons at the bottom of this)

When you have identified the server, you would normally save the connection string in your applications configuration file, so that you do not have to modify you program for each PC your program is to run on. If you are using SQL Server as a single user database, then you could fairly easily convert your app to use a standalone database such as SQLCE (which requires no installation other than .NET and the actual database file) or SQLLite which requires a little more installation effort, but not much.


You should not include SQL Server in your installation. There are a couple of reasons:
0) You can only distribute SQL Server Express for copyright reasons - not SQL Server full version.
1) They may already have SQL Server installed on the network. If so, then they will presumably want to use that version.
2) If they do have SQL server installed and you start proliferating SQL server Express instances, you are going to annoy the heck out of the database administrator...
3) A single site installation of SQl Server is a lot more likely to be backed up than a number of scattered version under user control.
4) Sql server is quite complex for a "normal" user to install and administer - it is not a good idea!
5) It will destroy the primary advantage of using Sql Server over SqlCE or SQLite - multiuser access. If everyone installs their own copy of SQL server, then you will have multiple copies of your database, each used by a single person. This will cause some confusion, and (depending on how you wrote the original database) may take some considerable effort to combine into a single instance when the problem is realized.


这篇关于SQL Server Express应用程序帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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