[英]How to fix "An unhandled exception occurred during the execution of the current web request. "
I am trying to host an Asp.Net website with a database.我正在尝试使用数据库托管一个 Asp.Net 网站。 It's giving me an error, of can't open the database
它给了我一个错误,无法打开数据库
I have tried to change the connection string but to no avail.我尝试更改连接字符串但无济于事。
This is the connection string:这是连接字符串:
<connectionStrings>
<add name="WebSqlConnectionString"
connectionString="Data Source=MXOLISI\MSSQLSERVER2;,1432 ;database=NCEDA2014;User ID=NCEDA14;Password=7n63rDYtp38Ymfd;"/>
</connectionStrings>`
I expect for the webpage to open the default page我希望网页打开默认页面
As the error clearly says your connection string has a wrong format.由于错误清楚地表明您的连接字符串格式错误。
<connectionStrings>
<add name="WebSqlConnectionString" connectionString="Data Source=MXOLISI\MSSQLSERVER2,1432;
database=NCEDA2014; User ID=NCEDA14;Password=7n63rDYtp38Ymfd;"/>
</connectionStrings>
You placed port number after semicolon which is not correct, it should be after server name.您在分号后放置了端口号,这是不正确的,它应该在服务器名称之后。
Try these steps first:首先尝试以下步骤:
Open SQL server and try to access the database with the credentials mentioned in the config file.打开 SQL 服务器并尝试使用配置文件中提到的凭据访问数据库。 If it works fine, follow next step.
如果它工作正常,请执行下一步。
Check your connection string.检查您的连接字符串。 Use below code as you are having issue in your connection string:
当您的连接字符串出现问题时,请使用以下代码:
<add key="myConnectionString" value="server=localhost;database=myDb;uid=myUser;password=myPass;" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.