Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Try
Using conn As MySQLConnection = New MySQLConnection( _
New MySQLConnectionString("localhost", _
"mysql", _
"root", _
"", _
3306).AsString)
conn.Open()
Using cmd As MySQLCommand = New MySQLCommand( _
"select host,user from mysql.user", conn)
Dim red As MySQLDataReader
red = cmd.ExecuteReaderEx()
While (red.Read())
Console.WriteLine("Host:{0} , User:{0}", _
red("Host"), red("User"))
End While
red.Close()
End Using
End Using
Catch ex As MySQLException
MessageBox.Show(ex.Message, "MySQLエラー")
Catch ex As Exception
MessageBox.Show(ex.Message, "一般エラー")
End Try
MessageBox.Show("処理完了")
End Sub
|