如何部署与数据库连接的asp.net应用程序 [英] How to deploy an asp.net application which is connected with database

查看:58
本文介绍了如何部署与数据库连接的asp.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我想将我的asp.net Web应用程序部署到另一台PC上。我正在使用SQL服务器数据库。我已经将数据库备份并上传到主机PC。但是主机PC SQL服务器凭据是不同的(用户名,密码..等)。

我在.cs文件中使用连接字符串。我是否需要更改.cs文件中的所有连接字符串或者还有其他方法吗?



提前致谢。

解决方案

而不是在cs中生成连接字符串,最好在web.config中使用连接字符串。



所以,当你发布到不同的服务器,只需更改web.config。



http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config [ ^ ]



SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ConnectionStringNameFromWebConfig]。ConnectionString);



希望这会有所帮助。 />


欢呼


您好,

当您尝试访问位于没有域控制器的LAN内的PC上的SQL SERVER数据库时,通常会发生这种情况,您应该将连接字符串窗口集成安全性更改为SQL安全的服务器连接,你可以从任何应用程序访问SQL服务。



另一个要考虑的问题是:如果数据库服务器主机和Web服务器(IIS)同样严重到足以给予数据库用户ASPNET或IUSR HOST的访问权限。



我希望我有所帮助,如果您有疑问,请告诉我

Dear All,
I want to deploy my asp.net web application into another PC. I am using SQL server database. I have taken the database backup and uploaded into host PC. But Host PC SQL server credentials are different( username, password..etc).
I am using connection string in my .cs files. Do I need to change all the connection string in .cs file or is there any other way?

Thanks in advance.

解决方案

Instead of generating the connection string in cs, it would be a best practice to use connection string in web.config.

So, when you publish to different server, just change the web.config.

http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config[^]

SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringNameFromWebConfig"].ConnectionString);

Hope this helps.

cheers


Hello,
This usually happens when you try to access a SQL SERVER database located on a PC within a LAN that does not have a domain controller, you should change your connection string windows integrated security to SQL Server connection safely , with this you can access from any application to SQL service.

Another point to consider is: if the database server host and the web server (IIS) are the same just serious enough to give access permissions to the database user ASPNET or IUSR HOST.

I hope I have been helpful, tell me if you have questions


这篇关于如何部署与数据库连接的asp.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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