更改连接字符串以使应用程序可在线访问 [英] Change of connection string to make application online accessable

查看:76
本文介绍了更改连接字符串以使应用程序可在线访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个使用SQL Server数据库的winforms应用程序。数据源中的连接字符串类似于



Hi,
I have a winforms application that uses SQL Server Databases. The connection string in data source is something like

Data Source=Office1\SQLEXPRESS;Initial Catalog=dbRepHost;Integrated Security=True







现在我已在网络服务器上托管数据库以访问在线数据库。我已经附加了数据库。



新的必需连接字符串是




Now I have hosted the DBs on a web server to access the online DBs. I have attached the DBs.

The new required connection string is

Data Source=dbRepHost.mssql.somee.com;Initial Catalog=dbRepHost;Persist Security Info=True;User ID=nouman;Password=abc123





我的问题是如果它足以改变app.config文件中的连接字符串,或者我需要编辑所有数据集并更改连接字符串?





谢谢



My question is if it is enough to change the connection string in app.config file or I need to edit all data sets to and change the connection string?


Thanks

推荐答案

理想情况下,如果你已经完成了正确的编码,你只需要更改App.Config而不需要其他任何内容。

这正是在App.Config中存储连接字符串的好处。



如果没有,你应该看看改变你的代码,以便你拿起连接字符串来自这个文件。
Ideally, if you have done your coding right, you should only need to change App.Config and nothing else.
That is exactly the benefit of storing connection string in App.Config.

If not, you should look at changing your code so that you pick up the connection string from this file.


从你的新连接字符串的外观来看,它看起来就像是在互联网上的某个地方托管它。



Microsoft SQL服务器需要打开某些端口才能通过防火墙进行通信。默认的SQL Server端口是1433,客户端端口被分配了1024到5000之间的随机值。



现在,如果此服务器在互联网上:* don''打开那些端口*,除非你知道你在做什么。



请阅读加密与SQL Server的连接 [ ^ ] - 甚至更好:将数据层公开为Web服务,并使用SSL与该Web服务进行通信。



最好的问候

Espen Harlinn
From the look of your new connection string, it looks like you''re hosting it somewhere on the internet.

Microsoft SQL Server requires certain ports to be opened to communicate over a firewall. The default SQL Server port is 1433, and client ports are assigned a random value between 1024 and 5000.

Now if this server is on the internet: *don''t open those ports*, unless you know what you are doing.

Please read Encrypting Connections to SQL Server[^] - or even better: Expose you datalayer as a web-service, and use SSL to communicate with that web service.

Best regards
Espen Harlinn


这篇关于更改连接字符串以使应用程序可在线访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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