网站托管后的数据库访问问题. [英] Database access problem after site hosted.

查看:65
本文介绍了网站托管后的数据库访问问题.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经托管了一个网站.我正在使用的数据连接是(web.config文件)

Hi,
I have hosted a website. The dataconnection I am using is (web.config file)

<add name="dbTestConnectionString" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\dbTest.mdf;Integrated Security=True;User Instance=True" providername="System.Data.SqlClient" />



它在localhost上运行良好,但是当通过Internet运行时,出现错误,表明无法访问数据库. (有关详细错误,请访问http://www.ezitek.somee.com)
我想我需要更改连接字符串,但是我不知道该怎么办.

托管后,我的数据库位于解决方案的App_Data文件夹中,该文件夹已按原样上传.

我的房东给了我以下细节:

网站本地路径:d:\ DZHosts \ LocalUser \ fsehgal \ www.ezitek.somee.com
受保护的本地路径:d:\ DZHosts \ LocalUser \ fsehgal \ Protected.ezitek.somee.com

请告知如何避免此错误.

非常感谢.
最好的问候,
Furqan



It works fine on the localhost but when run over the internet, it gives error that access to databse is not possible. (please visit http://www.ezitek.somee.com for detailed error)
I think I need to change the connection string, but I do not know what to do.

When hosted, my database is in App_Data folder of my solution, which has been uploaded as it is.

My host has given me the following detail:

Website local path: d:\DZHosts\LocalUser\fsehgal\www.ezitek.somee.com
Protected local path: d:\DZHosts\LocalUser\fsehgal\Protected.ezitek.somee.com

Please advise what to do to avoid this error.

Thank you very much.
With best regards,
Furqan

推荐答案

使用连接字符串作为
use connection string as
Data Source=OMX11SFD;Initial Catalog=omx;Persist Security Info=True;User ID=sa;Password=uuuu@!"


在您的Web配置文件中.
希望它能起作用.


in your web config file.
Hope it Works.


我认为ConnectionString您尝试此代码时遇到问题.

在Web.cofig中使用下面的代码
I think ConnectionString Problem you try this code.

Use bellow code in Web.cofig
<connectionStrings>
   <!--<add name="OsmEmpConString" connectionString="Data Source=.\sqlexpress;Initial Catalog=Reg.Mdf; "  providerName="System.Data.SqlClient" />-->
   <add name="OsmEmpConString" connectionString="Data Source=.\sqlexpress;Integrated Security=SSPI;AttachDBFilename=C:\Documents and Settings\Administrator\My Documents\Downloads\Rags_Modified\Rags\Rags\App_Data\Reg.mdf;User Instance=true" providerName="System.Data.SqlClient"/>

   <add name="SomeDataBase" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=C:\Documents and Settings\Administrator\My Documents\Downloads\Rags_Modified\Rags\Rags\App_Data\Reg.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True" providerName="System.Data.SqlClient"/>

   <!--<add name="SomeDataBase" connectionString="Data Source=.\SQLEXPRESS; AttachDbFilename=C:\App_Data\Reg.mdf; Integrated Security=True; Connect Timeout=30; User Instance=True"  providerName="System.Data.SqlClient" />-->

 </connectionStrings>



在后面的代码中



In code behind

string constr = ConfigurationManager.ConnectionStrings["SomeDataBase"].ToString();


这篇关于网站托管后的数据库访问问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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