如何将连接字符串的web.config文件中的IP地址? [英] How do I put connection string with IP Address inside web.config file?

查看:354
本文介绍了如何将连接字符串的web.config文件中的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前正在使用下面的连接字符串在我们的web.config文件:

 添加名称=DBConnectionString的connectionString =数据源= ourServer;初始目录= ourDB;坚持安全信息= TRUE;用户ID = theUserName;密码= thePassword的providerName =系统.Data.SqlClient/>

这工作正常。不过,这个程序需要推到我们的外部服务器。这意味着,根据我们的基础架构团队,我们将需要IP地址和端口1433连接字符串能够将应用程序连接到我们的数据库是不一样的外部服务器上。

我曾尝试任何下面的两个连接字符串,但他们没有工作。

第一个不报错了,但就是不承认分贝。我怀疑这是因为该位

  TCP:10.database.windows.net

我需要用IP地址来代替它?有人告诉我我需要的TCP在那里。

 <添加名称=DBConnectionString的providerName =System.Data.SqlClient的的connectionString =数据源= TCP:10.database.windows.net,1433;初始目录= POLLWORKER_TRAINING;集成安全性= FALSE;用户ID = pworker;密码= pworker;加密= TRUE; MultipleActiveResultSets = TRUE/>

这最后一项是导致它说的错误,


  

元素是connectionStrings不能包含文本。预计,增加,删除可能元素的列表,清除


 <添加名称=DBConnectionString的connectionString =供应商= SQLOLEDB;数据= 10.22.5.20,1433;网络库= DBMSSOCN;初始目录= ourDB;用户ID = theUserName;密码= thePassword/>


解决方案

数据= 10.22.5.20,1433 在连接字符串中应该是:

数据源= 10.22.5.20,1433

有关详细信息,请参阅: SQL连接字符串

We are currently using the following connection string in our web.config file:

add name="DBConnectionString" connectionString="Data Source=ourServer;Initial Catalog=ourDB;Persist Security Info=True;User ID=theUserName;Password=thePassword" providerName="System.Data.SqlClient" />

This works fine. However, this app needs to be pushed to our external server. This means, according to our infrastructure team that we will need a connection string with ip address and port 1433 to be able to connect the app to our db which is not on the same external server.

I have tried any of the two connection strings below but they don't work.

The first one doesn't error out but just doesn't recognize the db. I suspect it is because of this bit

tcp:10.database.windows.net

Do I need to replace it with IP Address? I am told I need the tcp in there.

<add name="DBConnectionString" providerName="System.Data.SqlClient" connectionString="Data Source=tcp:10.database.windows.net,1433;Initial Catalog=POLLWORKER_TRAINING;Integrated Security=False;User Id=pworker;Password=pworker;Encrypt=True;MultipleActiveResultSets=True" />

This last one is causing an error which says,

the element connectionStrings cannot contain text. List of possible elements expected, "add", "remove", "clear"

<add name="DBConnectionString" connectionString="Provider=sqloledb;Data=10.22.5.20,1433;Network Library=DBMSSOCN;Initial Catalog=ourDB;User ID=theUserName;Password=thePassword" />

解决方案

This Data=10.22.5.20,1433 in your connection string should be:

Data Source=10.22.5.20,1433

For more details see: SQL Connection Strings

这篇关于如何将连接字符串的web.config文件中的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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