本文介绍了ASP.NET MVC3:连接字符串 - 关键字不支持:“初始目录”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Webmatrix.data的数据库实体创建一个数据库连接,但它不喜欢我的连接字符串。我从MVC的ASP运行它。
I am using Webmatrix.data's Database entity to create a database connection, however it doesnt like my connection string. I am running it from MVC ASP.
伊夫试图将其更改为服务器/数据库,但仍错误是一样的。我在哪里去了?
Ive tried changing it to server / database, but still errors the same. Where am I going wrong?
using (var db = Database.OpenConnectionString(@"Data Source=MY-HP\Serv;Initial Catalog=MyDBSQL;User ID=sa;Password=password")) { var items = db.Query("SELECT * FROM TaskPriority"); }异常详细信息:System.ArgumentException:不支持关键字:初始目录
推荐答案点击这里:Database.OpenConnectionString方法(字符串,字符串)
尝试指定提供者的名称作为第二个参数,从MSDN例如:
try to specify the provider name as second parameter, from the MSDN example:
var connectionString = "Data Source=.\\SQLExpress;Initial Catalog=SmallBakery;Integrated Security=True"; var providerName = "System.Data.SqlClient"; var db = Database.OpenConnectionString(connectionString, providerName);更多推荐
ASP.NET MVC3:连接字符串
发布评论