[ create a new paste ] login | about

Link: http://codepad.org/5CQvl2t7    [ raw code | fork ]

Plain Text, pasted on May 4:
Imports MySql.Data.MySqlClient
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As MySqlConnection
        Dim cmd As MySqlCommand
        Dim dr As MySqlDataReader

        Dim conStr As String
        Dim sqlStr As String

        '接続文字列
        conStr = "server=192.168.20.14;database=test;user id=root;password=pass1234"

        'コネクション生成
        con = New MySqlConnection(conStr)

        '接続
        con.Open()

        'SQL文
        sqlStr = "select * from test"

        'MySQLCommand
        cmd = New MySqlCommand(sqlStr, con)

        '実行
        dr = cmd.ExecuteReader

        '結果
        While dr.Read()
            Console.WriteLine(CStr(dr("id")) + ":" + dr("name"))
        End While

        '接続をクローズ
        con.Close()
    End Sub
End Class


Create a new paste based on this one


Comments: