如何解决“在执行当前Web请求期间发生未处理的异常。”

时间:2019-04-12 13:25:14

标签: c# asp.net sqlclient

我试图用数据库托管一个Asp.Net网站。这给我一个错误,无法打开数据库

我尝试更改连接字符串,但无济于事。

这是连接字符串:

<connectionStrings>
   <add name="WebSqlConnectionString" 
        connectionString="Data Source=MXOLISI\MSSQLSERVER2;,1432 ;database=NCEDA2014;User ID=NCEDA14;Password=7n63rDYtp38Ymfd;"/>
</connectionStrings>`

exception another exception

我希望网页打开默认页面

2 个答案:

答案 0 :(得分:0)

该错误明确表明您的连接字符串格式错误。

<connectionStrings>
    <add name="WebSqlConnectionString" connectionString="Data Source=MXOLISI\MSSQLSERVER2,1432;
       database=NCEDA2014; User ID=NCEDA14;Password=7n63rDYtp38Ymfd;"/>
</connectionStrings>

您将端口号放在分号后面,这是不正确的,应该在服务器名称之后。

答案 1 :(得分:0)

Try these steps first:

1- Open SQl server and try to access the database  with the credentials mentioned in the config file. If it works fine ,follow next step.
2. Check your connection string . use below code as you are having issue  in your conection string:

<add key="myConnectionString" value="server=localhost;database=myDb;uid=myUser;password=myPass;" />