4

我添加了一个连接,它显示在“其他连接”中,但我似乎无法引用它。

var db = Database.Open("MyNewConnection");

抛出异常:Connection string 'MyNewConnection' was not found.

4

1 回答 1

6

您是否检查过 web.config 文件中的连接字符串是否正确?

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <connectionStrings>
   <add 
     name="MyNewConnection" 
     connectionString= "server=myServer;database=myDatabase;uid=username;pwd=password"
     providerName="System.Data.SqlClient" /> 

  </connectionStrings>
</configuration>
于 2010-09-17T21:10:30.597 回答