我怎样才能从Windows窗体连接到MySQL?

如何从Windows窗体连接到MySQL数据库?

连接字符串的很多示例在这里: http : //www.connectionstrings.com/

从这里使用连接器 。 还有一个文件 。

这里是一篇关于使用Connector / Net 6.0连接到mysql的完整文章。

或者,您也可以使用OleDb连接到MySql。

private void button1_Click(object sender, System.EventArgs e) { string MyConString = "SERVER=localhost;" +"DATABASE=mydatabase;" "UID=testuser;" +"PASSWORD=testpassword;"; MySqlConnection connection = new MySqlConnection(MyConString); MySqlCommand command = connection.CreateCommand(); MySqlDataReader Reader; command.CommandText = "select * from mycustomers"; connection.Open(); Reader = command.ExecuteReader(); while (Reader.Read()) { string thisrow = ""; for (int i = 0;i<Reader.FieldCount;i++) thisrow += Reader.GetValue(i).ToString() + ","; listBox1.Items.Add(thisrow); } connection.Close(); } 

我认为这将是简单的一个权利! 但thanx你们所有的人作出回应,并提供我的文件!