"由于复制数据库文件失败而无法生成SQL Server的用户实例。连接将被关闭“如何解决这个错误? [英] " Failed to generate a user instance of SQL server due to failure in copying database files.the connection will be closed" how to solve this error?

查看:192
本文介绍了"由于复制数据库文件失败而无法生成SQL Server的用户实例。连接将被关闭“如何解决这个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在winforms中开发了应用程序,但是当我打开n客户端计算机时出现错误..

由于复制数据库文件失败而无法生成sql server的用户实例。连接将被关闭

请给我解决方案。我的app.config中的连接字符串和代码如下,

<?xml version =1.0? >

< configuration>



< connectionstrings>

< add name =LN。 Properties.Settings.dbLnConnectionString

connectionString =Data Source = myPC; Initial Catalog = dbLn; User ID = sa; Password = sa123; User Instance = True

providerName =System.Data.SqlClient/>







< system.windows.forms jitDebugging =true/>



< startup>< supportedRuntime version =v4.0sku =。NETFramework,Version = v4.0 />



但是这个错误仍然发生,plz给我解决方案。我有面对这个p Roblem从15天开始



我尝试过:



< connectionstrings> ;

< add name =LN.Properties.Settings.dbLnConnectionString

connectionString =Data Source = myPC; Attachfilename = DataDirectory | dbLn.mdf; User ID = sa;密码= sa123;用户实例=真

providerName =System.Data.SqlClient/>

I have develpoed application in winforms ,but when i open n client machine there are error occured..
" failed to generate a user instance of sql server due to failure in copying database files.the connection will be closed"
please give me solution for this .My connection string and code in app.config is following,
<?xml version="1.0"?>
<configuration>

<connectionstrings>
<add name="LN.Properties.Settings.dbLnConnectionString"
connectionString="Data Source=myPC;Initial Catalog=dbLn;User ID=sa;Password=sa123;User Instance=True"
providerName="System.Data.SqlClient" />



<system.windows.forms jitDebugging="true" />

<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

But still this error occured,plz give me solution.i have face this problem since 15days

What I have tried:

<connectionstrings>
<add name="LN.Properties.Settings.dbLnConnectionString"
connectionString="Data Source=myPC;Attachfilename=DataDirectory|dbLn.mdf;User ID=sa;Password=sa123;User Instance=True"
providerName="System.Data.SqlClient" />

推荐答案

当我当你早先发布时说:

As I said when you posted this earlier:
Quote:

该字符串看起来不对:

数据源= myPC不太可能 - 你通常也有一个SQL实例名称。

Provider = ...不是SQL Server支持的关键字。 br $> b $ b

看看这里:

简单的SQL连接字符串创建 [ ^ ]

它应该可以帮助您(和您的客户)生成有效的连接。



BTW:不推荐sa用户 - 你应该创建一个具有足够权限的用户来完成应用程序的工作。 sa可以完全访问所有数据库,并且可以对系统执行任何操作。使用它会将您的管理员登录信息暴露给临时用户,如果代码中出现错误,则会使事情处于危险之中。

That string doesn't look right:
"Data Source=myPC" is unlikely - you'd normally have an SQL instance name on that as well.
"Provider=..." is not a keyword SQL Server supports.

Have a look here:
Simple SQL Connection String Creation[^]
It should help you (and your client) generate a working connection.

BTW: The sa user is not recommended - you should create a user with just enough permission to to the app's job. "sa" has full access to all DB's and can do anything to the system. Using that exposes your admin login to casual users, and puts things move at risk if there is an error in your code.


这篇关于&QUOT;由于复制数据库文件失败而无法生成SQL Server的用户实例。连接将被关闭“如何解决这个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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