[英]How do I connect to a SQL Server database using WebMatrix?
I added a connection and it shows up in "Other Connections" but I can't seem to reference it. 我添加了一个连接,它显示在“其他连接”中,但我似乎无法引用它。
var db = Database.Open("MyNewConnection");
throws an exception: Connection string 'MyNewConnection' was not found.
抛出异常:
Connection string 'MyNewConnection' was not found.
Have you checked to make sure your connection string is correct in your web.config file? 您是否检查过以确保您的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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.