与数据库不在客户端的系统上运行的C#Windows窗体应用程序 [英] C# Windows Form Application with Database not running on Client's System

查看:136
本文介绍了与数据库不在客户端的系统上运行的C#Windows窗体应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了在C#中使用SQL Server数据库的连接Windows窗体应用程序。我在.NET框架4.0和SQL Server 2008 R2开发它。我的应用程序使用本地数据库中存在一个名为 AG.mdf 应用程序的根目录。

I have developed a Windows Form Application in C# that uses SQL Server database connectivity. I developed it in .NET Framework 4.0 and SQL Server 2008 R2. My application is using a local database present in the root directory of the application called AG.mdf.

这是我的连接字符串:

Data Source=.;AttachDbFilename=|DataDirectory|\\AG.mdf;Integrated     Security=True;User Instance=True 

我通过添加安装项目的Visual Studio安装模板内为我的应用程序的新项目创建的安装程序。我生成安装项目,并创建了安装程序对我来说。我部署了我的用户的系统上的应用程序,该应用程序刚开始启动,但随后突然弹出

I created the installer by adding Setup Project inside Visual Studio installer template as a new project in my application. I build the Setup project and it created the installer for me. I deployed the application on my User's system, the application starts initially but then it suddenly pops up an error

未处理的异常发生在您的应用程序错误。如果单击继续,应用程序将忽略该消息并尝试继续。如果你点击退出,应用程序将立即关闭。

Unhandled exception has occurred in your application. If you click continue, the application will ignore this message and attempt to continue. If you click quit, the application will close immediately.

建立SQL Server的连接时发生网络相关的或特定于实例的错误。服务器未找到或无法访问。验证实例名称是否正确,以及SQL Server配置为允许远程连接。 (provider:命名管道提供程序,error:40 - 无法打开到SQL Server的连接)

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

PS:我有!我的用户的系统上安装的.NET Framework 4.0和SQL Server精简版,以及

我应该退出编程:(

推荐答案

非常感谢大家的帮助。我已经解决了我自己的这个问题。我唯一关心的是有关客户端的计算机上安装SQL Server,但后来我意识到我必须为了使我的应用程序运行安装客户端的系统上的数据库管理工具(SQL Server)的。

因此,我的客户端机器上安装了SQL Server Express和改变我的查询字符串了一下,如下结果

Thanks a lot everyone for your help. I have solved this problem on my own. My only concern was about installing the SQL Server on client's machine but later i realized that i have to install a Database management tool (SQL Server) on client's system in order to make my application run.
Hence, I installed SQL Server Express on client's machine and change my QueryString a bit, as follows

数据源= .\SQLEXPRESS; AttachDbFilename = | DataDirectory目录| \AG.mdf;数据库= AG;集成安全=真;用户实例=真; Trusted_Connection =是结果。

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AG.mdf;Database=AG;Integrated Security=True;User Instance=True;Trusted_Connection=Yes

此外,我也给在完全控制权限允许,其中包含我部署的应用程序文件夹上,使点网框架在我的应用程序可以访问部署密度纤维板数据库结果
编码愉快! :)

Moreover, i also gave the Full Control Permission as Allow on that folder which contains my deployed application, so that Dot Net Framework in my application can access the deployed .mdf database
Happy coding! :)

这篇关于与数据库不在客户端的系统上运行的C#Windows窗体应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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