网络上的连接字符串 [英] Connection string over network

查看:90
本文介绍了网络上的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PC 1上开发了带有数据库的Windows应用程序
该软件正在运行 will ,我在PC 2上安装了相同的软件
而且我不知道如何使PC 2上的软件查看PC 1的数据库

我应该如何制作连接字符串?
我尝试了很多类似的事情:

i have developed a windows application with database on PC 1
the software is running will well , i setup the same software on PC 2
and i don''t know how make the software on PC 2 see the database of PC 1

how should i make the connection string ???

i try many things like this :

ConnectionString = "Network Library=DBMSSOCN;" & _
                            "Data Source=xxx.xxx.xxx.xxx,1433;" & _
                            "Initial Catalog=mySQLServerDBName;" & _
                            "User ID=myUsername;" & _
                            "Password=myPassword"



其中:
-网络库= DBMSSOCN"告诉SqlConnection使用TCP/IP
-xxx.xxx.xxx.xxx是IP地址.
-1433是SQL Server的默认端口号
-您也可以添加"Encrypt = yes"进行加密
</b>

它不起作用:(



Where:
- "Network Library=DBMSSOCN" tells SqlConnection to use TCP/IP
- xxx.xxx.xxx.xxx is an IP address.
- 1433 is the default port number for SQL Server
- You can also add "Encrypt=yes" for encryption
</b>

it doesn''t work :(

推荐答案

请看看

位于另一个程序中的连接数据库 [
Please have a look

connect database located in another program[^]

:)


更改安全认证模式

在SQL Server Management Studio对象资源管理器中,右键单击服务器,然后单击属性".

在安全性"页上的服务器身份验证"下,选择新的服务器身份验证模式,然后单击确定".

在"SQL Server Management Studio"对话框中,单击确定"以确认重新启动SQL Server的要求.

在对象资源管理器中,右键单击您的服务器,然后单击重新启动".如果SQL Server代理正在运行,则还必须重新启动它.

启用sa登录

在对象资源管理器中,依次展开安全性",登录名",右键单击"sa",然后单击属性".

在常规"页面上,您可能必须创建并确认登录密码.

在状态"页面上的登录"部分中,单击启用",然后单击确定".

然后使您的连接字符串如下所示:

添加名称="Connection_String" providerName ="System.Data.SqlClient" connectionString =数据源= xxx.xxx.x.xxx,1433;初始目录=数据库名称;持久性安全信息=真实;用户ID = UID;密码=密码"

及其工作原理:)
change security authentication mode

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.

On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

To enable the sa login

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.

On the General page, you might have to create and confirm a password for the login.

On the Status page, in the Login section, click Enabled, and then click OK.

and then make your connection string as the following :

add name ="Connection_String" providerName="System.Data.SqlClient" connectionString="Data Source=xxx.xxx.x.xxx,1433;Initial Catalog=DatabaseName;Persist Security Info=True;User ID=UID;Password=password "

and its worked :)



首先,您需要允许远程连接.转到以下链接:
support.microsoft.com/kb/914277

然后,您可以使用IP地址访问它,例如数据源= 192.168.155.144 \ SQLEXPRESS;用户ID = sa;密码=密码;初始目录=测试"
Hi,
First you need to allow remote connection. Go to following link :
support.microsoft.com/kb/914277

Then you can access it using IP address like, "Data Source=192.168.155.144\SQLEXPRESS;User Id=sa;Password=pass;Initial Catalog=test"


这篇关于网络上的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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