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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
Public sConnection As New MySqlConnection
Private Sub Rapport_auto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If sConnection.State = ConnectionState.Closed Then
sConnection.ConnectionString = "SERVER = localhost; USERID = root; PASSWORD =; DATABASE = ?????"
sConnection.Open()
LoadPeople()
End If
DateTimePicker1.Text = BDDDate
ComboBox1.Text = BDDNom
ComboBox2.Text = BDDPoste
RichTextBox1.Text = BDDRapport
End Sub
Public Sub LoadPeople()
Dim sqlQuery As String = " SELECT * FROM rapport_automaticien"
Dim SqlAdapter As New MySqlDataAdapter
Dim sqlCommand As New MySqlCommand
Dim TABLE As New DataTable
With sqlCommand
.CommandText = sqlQuery
.Connection = sConnection
End With
With SqlAdapter
.SelectCommand = sqlCommand
.Fill(TABLE)
ListView1.Items.Clear()
For i = 0 To TABLE.Rows.Count - 1
With ListView1
.Items.Add(TABLE.Rows(i)("id"))
With .Items(.Items.Count - 1).SubItems
.Add(TABLE.Rows(i)("BDDDate"))
.Add(TABLE.Rows(i)("BDDNom"))
.Add(TABLE.Rows(i)("BDDPoste"))
.Add(TABLE.Rows(i)("BDDRapport"))
End With
End With
Next
End With
End Sub
Private Sub Ajouter_rapport_bdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ajouter_bdd.Click
If sConnection.State = ConnectionState.Closed Then
sConnection.ConnectionString = " SERVER = localhost; USEID = root ; PASSWORD =; DATABASE = ????"
sConnection.Open()
End If
Dim sqlQuery As String = " INSERT INTO rapport_automaticien(BDDDate,BDDNom,BDDPoste,BDDRapport) VALUES ('" & DateTimePicker1.Text & _
"','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" & RichTextBox1.Text & "')"
Dim sqlCommand As New MySqlCommand
With sqlCommand
.CommandText = sqlQuery
.Connection = sConnection
.ExecuteNonQuery()
End With
MsgBox("Rapport Ajouter")
Me.LoadPeople()
End Sub |
Partager