【问题标题】:error while making connection in mvc .net (system.data.common.dbconnection)在 mvc .net 中建立连接时出错(system.data.common.dbconnection)
【发布时间】:2017-11-15 15:05:16
【问题描述】:

我是 mvc 新手,正在尝试使用 mvc 将我的 mysql 数据库连接到应用程序。

我的连接字符串是 as-

<connectionString>
    <add name ="Controlsheetlogin" connectionString="Server=localhost; database=test;User Id=root;password=123"/>
</connectionString>

this is my connection string

并且在 MySql.Data.MySqlClient.MySqlCommand 中出现错误 提前感谢您的帮助。

and this is the error that i am getting

【问题讨论】:

  • 您可以改为搜索该错误。也许 Stack Overflow 上有一个问题可以帮助您解决这个具体案例。
  • 如果相关错误,您能否发布出现错误的 C# 方法?
  • 在文本中包含异常会很有帮助。
  • string constr = ConfigurationManager.ConnectionStrings["abc"].ConnectionString using (MySqlConnection con = new MySqlConnection(constr)) { using (MySqlCommand cmd = new MySqlCommand() ) 使用时出错跨度>

标签: c# mysql asp.net asp.net-mvc asp.net-mvc-4


【解决方案1】:

您的连接字符串看起来不正确。要将 EF 连接到 MySQL,您需要指定提供程序:

[...] name="ConnectionString" providerName="MySql.Data.MySqlClient" [...]

对此question 的回答可能会有所帮助,因为它详细说明了如何使用 MySQL 设置 EF。

【讨论】:

  • 从您遇到的错误的屏幕截图中,您似乎遗漏了一些参考资料...您能否发布您的 C# 代码以便我们进一步帮助您?
  • 我的意思是用相关的 C# 代码编辑你的问题(至少是你在评论中的完整 using 块,但很难阅读)和顶部的 using(s) 声明作为错误消息指向缺少的引用...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-04-28
  • 1970-01-01
  • 2021-06-14
  • 1970-01-01
  • 1970-01-01
  • 2017-08-23
  • 1970-01-01
相关资源
最近更新 更多