Advertisement
Guest User

cocozinho

a guest
Apr 1st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Dim sql As String
  2. Dim registos As MySqlDataReader
  3. Dim adaptador As New MySqlDataAdapter
  4. Dim dados As New DataTable
  5. 'Dim ds As New DataSet
  6. Dim bsource As New BindingSource
  7. Dim conexao As New MySqlConnection()
  8. conexao.ConnectionString = "SERVER=localhost; user=root; password='';database=bd_loja" ' atribui a string de ligação a conexão a BD
  9.  
  10. sql = "SELECT * FROM clientes"
  11.  
  12. Try
  13. conexao.Open()
  14.  
  15. Dim comando As MySqlCommand = New MySqlCommand(sql, conexao)
  16.  
  17. adaptador.SelectCommand = comando
  18. adaptador.Fill(dados)
  19. bsource.DataSource = dados
  20. cons_clientes.DataSource = bsource
  21. adaptador.Update(dados)
  22.  
  23. conexao.Close()
  24.  
  25. Catch ex As Exception
  26. MessageBox.Show("Erro ao tentar ler a DB", ex.Message)
  27. Finally
  28. conexao.Dispose()
  29. End Try
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement