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 32 33 34 35 36 37 38 39 40 41 42 43
| Imports MySql.Data.MySqlClient
Public Class Form1
Dim oConn As New MySqlConnection
Dim IP, DBName, UserName, UserPassword As String
Private Sub B_Connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles B_Connect.Click
oConn.ConnectionString = "Server=" & IP & ";Database=" & DBName & ";Uid=" & UserName & ";Pwd=" & UserPassword & ";"
'Server=localhost;Database=MaBase;Uid=user;Pwd=mdp;
MsgBox("Server=" & IP & ";Database=" & DBName & ";Uid=" & UserName & ";Pwd=" & UserPassword & ";")
Try
oConn.Open()
Dim myCommand As New MySqlCommand
Dim MyAdapt As New MySqlDataAdapter
Dim myDataTable As New DataTable
Dim strQuery As String
strQuery = "SELECT Libelle FROM users"
myCommand.Connection = oConn
myCommand.CommandText = strQuery
MyAdapt.SelectCommand = myCommand
'MyAdapt.Fill(myDataTable)
'For i As Integer = 0 To myDataTable.Rows.Count - 1
' MsgBox(myDataTable.Rows(i)("monChamp").ToString)
'Next
Catch ex As Exception
DBStatus.Text = ex.Message
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
IP = BoxIP.Text
DBName = BoxDBName.Text
UserName = BoxUserName.Text
Userpassword = BoxUserPassword.Text
End Sub
End Class |
Partager