Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim conexao As New MySqlConnection()
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim sql As String
- Dim registos As MySqlDataReader
- conexao = New MySqlConnection
- conexao.ConnectionString = "SERVER=localhost; user=root; password=''; database=bd_escola"
- Try
- conexao.Open()
- Try
- sql = "SELECT modulos.moduloID FROM modulos"
- Dim comando As MySqlCommand = New MySqlCommand(sql, conexao)
- Try
- registos = comando.ExecuteReader
- While registos.Read
- modulo.Items.Add(registos("moduloID"))
- End While
- Finally
- conexao.Dispose()
- End Try
- Catch erro As MySqlException
- MessageBox.Show("Erro ao tentar ler a base de dados" & erro.Message)
- End Try
- Catch erro As MySqlException
- MessageBox.Show("Erro ao tentar ligar com o banco de dados", "atenção", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Finally
- conexao.Dispose()
- End Try
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement