我添加了一个连接,它显示在其他连接"中,但我似乎无法引用它.
I added a connection and it shows up in "Other Connections" but I can't seem to reference it.
var db = Database.Open("MyNewConnection");
抛出异常:未找到连接字符串MyNewConnection".
您是否检查过 web.config 文件中的连接字符串是否正确?
Have you checked to make sure your connection string is correct in your web.config file?
<?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>
这篇关于如何使用 WebMatrix 连接到 SQL Server 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!