【问题标题】:Keyword not supported不支持关键字
【发布时间】:2017-01-28 17:56:03
【问题描述】:

我看到了一大堆答案,但我仍然无法找到适合我的答案。

<connectionStrings>
    <add
      name="conString"
      connectionString="Data Source=(local);Initial Catalog=wb_lab_1;Integrated Security=True"
      providerName="System.Data.MysqlClient"
    />
</connectionStrings>

我无法使用 Windows 身份验证在 Windows 上创建连接字符串。我也试过:

Server=127.0.0.1;Database=wb_lab_1;IntegratedSecurity=yes;Uid=auth_windows;

Server=(local);Database=wb_lab_1;IntegratedSecurity=yes;Uid=auth_windows;

但我仍然遇到Keyword not supported 错误。我哪里错了?


UPD:这是我尝试在 C# 中连接的方式:

String connString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connString); // here I got an Exception

【问题讨论】:

  • 用`providerName="System.Data.SqlClient"`替换providerName`
  • @Smart,还是什么都没有。我也试过MySql.Data.MySqlClient
  • 你确定Date source 是正确的吗?
  • @Smart,是的,我可以在 MS SQL Server 中连接它,当我在 Visual Studio 中打开数据库时也会生成它。

标签: mysql sql asp.net windows connection


【解决方案1】:

变化:

String connString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ToString();
conn = new MySql.Data.MySqlClient.MySqlConnection(connString); // here I got an Exception

收件人:

String connString = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
conn = new System.Data.SqlClient.SqlConnection(connString); // should work

【讨论】:

  • 哇,当我全部更改为System.Data.SqlClient 时,它开始工作了!非常感谢!
  • 我在第一条评论中提到过将其更改为System.Data.SqlClient!!
  • 是的,看起来您正在尝试使用 MySQL 连接字符串连接到 MS SQL Server 数据库。请帮助。
  • @Smart 是的,你做到了。我认为它需要在两个位置进行更改。因此,这两种答案的结合似乎都奏效了。
【解决方案2】:

改变

providerName="System.Data.MysqlClient"

providerName="System.Data.SqlClient"

【讨论】:

  • 感谢回复,还是没有。
  • 你使用的是什么类型的数据库?
  • MS SQL Server 2008
  • 关键是将Mysql.Data.MysqlClient 处处更改为System.Data.SqlClient。感谢您的帮助!
  • 我在第一条评论中提到过,但不幸的是你没有选择它作为你的答案
猜你喜欢
  • 2011-06-06
  • 2019-07-08
  • 2017-07-04
  • 1970-01-01
  • 1970-01-01
  • 2012-03-03
  • 1970-01-01
  • 2017-09-24
  • 1970-01-01
相关资源
最近更新 更多