segunda-feira, 7 de novembro de 2011

on

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim myConnString = "Database=myDB; Data Source=192.168.1.100; User Id='auser'; Password='userpassword'"
        Dim conn As New MySql.Data.MySqlClient.MySqlConnection
        Dim myCommand As New MySqlCommand
        Dim myAdapter As New MySqlDataAdapter
        Dim myData As New DataTable
        Dim SQL As String
        SQL = "SELECT * FROM Professores"
        conn.ConnectionString = myConnString
        conn.Open()
        myCommand.Connection = conn
        myCommand.CommandText = SQL
        myAdapter.SelectCommand = myCommand
        myAdapter.Fill(myData)

        For Each drRow As DataRow In myData.Rows
            ListBox1.Items.Add(drRow.Item("ProfName").ToString)
        Next

    End Sub
End Class


0 comentários:

Postar um comentário