Datagridview + mysql + odbc













Imports System.Data.Odbc
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ConnString As String = "Dsn=modbc351mysql;Uid=admin;Pwd=p"
        Dim sql As String = "select user,password from user"
        '===============
        Dim oConn As OdbcConnection = New Odbc.OdbcConnection(ConnString)
        ' Dim strthai as String = "SET NAMES 'tis620'" 
        ' Dim cmdCat as New OdbcCommand(strthai,oConn)
        ' oConn.Open()
        ' cmdCat.ExecuteNonQuery()
        Dim CmdCat As OdbcCommand = New OdbcCommand(sql, oConn)
        oConn.Open()
        Dim ReaderCat As OdbcDataReader = CmdCat.ExecuteReader()
        Dim s As String = ""
        Do While ReaderCat.Read() : s &= ">" & ReaderCat.GetString(0) & Chr(10) : Loop
        MsgBox(s) : ReaderCat.Close() : oConn.Close()
        '===============
        Dim myConnection As OdbcConnection = New OdbcConnection
        myConnection.ConnectionString = ConnString
        myConnection.Open()
        Dim da As New OdbcDataAdapter(sql, myConnection)
        Dim CmdB As New OdbcCommandBuilder(da)
        Dim ds As New DataSet : da.Fill(ds, "user")
        Dim dv As New DataView : dv.Table = ds.Tables("user")
        DataGridView1.DataSource = dv
    End Sub
End Class

http://goo.gl/72BPC