ASP.NET MVC3:连接字符串

编程入门 行业动态 更新时间:2024-10-15 18:29:23
本文介绍了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:连接字符串

本文发布于:2023-11-03 18:51:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555816.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   ASP   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!