我试图在AppHarbor上启动并运行应用程序。大部分情况一直很顺利,但今天我无法连接到我的MySQL数据库。AppHarbor:通过ASP.NET MVC连接到MySQL数据库5 + Dapper
使用AppHarbor为我提供的凭据,使用dbForge Studio Express成功连接到mySQL数据库实例,创建了必需的SQL模式,并使用数据填充表格。现在,我尝试使用下面的C#代码中使用精致小巧做一个简单的查询:
var sqlConnStringBuilder = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["AppHarborMySql"].ConnectionString);
using (var db = new SqlConnection(sqlConnStringBuilder.ConnectionString))
{
db.Open();
// Do database query stuff
return result;
}
但是,这是我遇到的错误,当我尝试打开数据库连接:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
这是怎么了,我宣布在Web.config中的连接字符串:
<connectionStrings>
<add name="AppHarborMySql" connectionString="server=MYDOMAIN.mysql.sequelizer.com;database=MYDBNAME;uid=MYUSERNAME;pwd=MYPASSWORD" providerName="System.Data.SqlClient" />
</connectionStrings>
我失去了一些东西明显?我正在使用ASP.NET MVC 5.x和Dapper的最新版本......提前致谢!