1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Imports MySql.Data.MySqlClient
Public Class form1
Dim cmd As New MySqlCommand
'Represents a set of data commands and a database connection that
'are used to fill a dataset and update a MySQL database. This class cannot be inherited.
Dim da As New MySqlDataAdapter
Private Sub btnload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnload.Click
'again we do this because we do not yet declare this as global, but we do it for now beacause in later tutorial
'we will do the moduling and more on refactoring of codes
con.ConnectionString = ("server=localhost;user id=root;password=;database=test")
Try
con.Open()
With cmd
.Connection = con
'in this query it does simply selecting or getting all the user found in the database.
.CommandText = "Select * from utilisateur"
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
da.Dispose()
filltable(dtguser)
End Sub
End Class |
Partager