最好给个完整的源代码,谢谢
------解决思路----------------------
http://jingyan.baidu.com/article/8ebacdf023953f49f65cd589.html
这是百度里的一个vs2010连接mysql的例子,我将其改写为了vb.net
Imports MySql.Data.MySqlClient
Dim str As String = "Server=127.0.0.1;User ID=root;Password=123456;Database=test;CharSet=gbk;"
Dim con As New MySqlConnection(str)
'实例化链接
con.Open()
'开启连接
Dim strcmd As String = "select * from user"
Dim cmd As New MySqlCommand(strcmd, con)
Dim ada As New MySqlDataAdapter(cmd)
Dim ds As New DataSet()
ada.Fill(ds)
'查询结果填充数据集
dataGridView1.DataSource = ds.Tables(0)
'关闭连接
con.Close()
里面需要的MySql.Data.dll 在这里下载:
http://download.csdn.net/detail/u010940770/6519079