试图连接asp.net和mysql试图找出mysql.data.dll

时间:2019-01-04 01:03:39

标签: mysql asp.net .net

我正在尝试将asp.net项目连接到mysql,并下载了mysql安装程序。当我尝试添加参考时,信息为空白。我在哪里找到它?感谢您的任何帮助。我还选择了浏览=>并进入了安装程序,并在bin文件夹中查找,但没有找到mysqldata.dll

enter image description here

1 个答案:

答案 0 :(得分:0)

在您的\copy文件中:

粘贴web.Config

connectionStrings

<configuration> <connectionStrings> <add name="thisIsYourConnectionName" connectionString="uid=user1;pwd=YourPassword;server=localhost;database=yourdatabaseName;CharSet=utf8;" providerName="MySql.Data.MySqlClient" /> </connectionStrings> </configuration> DLL导入您的System.Configuration,并使用Page or Form DLL

在页面或表单中测试连接的示例:

MYSQL Data

确保已创建var connectionString = ConfigurationManager.ConnectionStrings["thisIsYourConnectionName"].ConnectionString; string queryString = "SELECT id,col1,col2,col3 FROM yourTableName;"; using (var connection = new MySqlConnection (connectionString)) { var command = new MySqlCommand(queryString, connection); connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { Console.WriteLine(String.Format("{0}, {1}", reader[0], reader[1])); } } } Database,并已将Tables创建到数据库。

您可以在Username and PasswordC:\Program Files (x86)\MySQL\MySQL Installer之类的地方找到mysql.data.dll