SQL连接到应用程序 [英] SQL Connection to Application

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

问题描述

亲爱的绅士,



当我在另一台计算机上使用我的应用程序并且我的数据库是本地的时,如果我可以开始工作,我的新应用程序连接数据库时遇到问题我的数据库在另一台计算机上,我使用C#语言和SQL Server 2012数据库



我希望能帮我解决这个问题



感谢和问候

解决方案

如果您使用的是SQL Server数据库,那么其他PC必须能够看到服务器计算机,通常在同一个LAN网段上。如果是这种情况,那么您需要做的就是生成一个不使用LOCALHOST的工作连接字符串(并且可能不使用Windows身份验证)。



尝试使用服务器资源管理器窗格在VS中设置连接:

1)打开服务器资源管理器。

2)右键单击数据连接并选择添加连接

3)在随后的对话框中,选择您的DataSource和数据库,指定安全信息,然后按测试连接按钮。

4)连接时工作,按确定

5)在服务器资源管理器窗格中突出显示数据库,然后查看属性窗格。将显示连接字符串的工作示例,您可以将其复制并粘贴到您的应用程序或配置文件中。



如果您的其他PC看不到与您的开发机器相同的SQL实例,那么您可能需要重新考虑您的应用程序:您是否需要多用户访问?如果您不这样做,那么更改您的应用程序以使用单个用户数据库(例如SqLite,SQLCE,甚至Access)可以很容易地进行安装(对您的用户来说也更简单)。

如果您这样做,那么您的用户需要在其网络上的一台PC上安装SQL Server,并且您需要在安装过程中安装数据库的副本(如果它不存在)。

Dear Gentleman,

I have problem with connecting database for my new application when i use my application in another computer and my database is local how can i start work my database in another computer, i use C# Language with SQL Server 2012 Database

I hope to help me to solve that

Thanks&Regards

解决方案

If you are using an SQL Server database, then the "other PC" has to be able to "see" the Server computer, normally on the same LAN segment. If this is the case, then all you need to do is generate a working connection string that doesn't use LOCALHOST (and probably doesn't use Windows Authentication).

Try setting up a connection in VS with the Server Explorer pane:
1) Open Server Explorer.
2) Right click "Data connections" and select "Add connection"
3) In the dialog that follows, select your DataSource, and database, specify the security info, and press the "Test connection" button.
4) When the connection works, press "OK"
5) Highlight your database in the Server Explorer pane, and look at the Properties pane. A working example of the connection string will be shown, which you can copy and paste into your app or config file.

If your "other PC" can't see the same SQL instance as your development machine, then you may need to rethink your application: do you need multi user access? If you don't then changing your app to use a single user DB (such as SqLite, SQLCE, or even Access) is a lot easy to work with for installation (and simpler for your user as well).
If you do, then your user needs to install SQL Server on one of the PC's on his network, and you need to install a copy of your DB (if it isn't there already) as part of your installation process.


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

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