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
| Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ticker = ""
'Requete SQL
conn = New MySqlConnection()
conn.ConnectionString = "server=sgbd_distante;user id=root;password=;database=sgbd;"
Try 'piege
'connexion
conn.Open()
RequeteSQLTimer = "SELECT ticker FROM system;"
'Execution de la requete
myCommandTimer = New MySqlCommand(RequeteSQLTimer, conn)
myReaderTimer = myCommandTimer.ExecuteReader
ticker = 1
conn.Close()
conn.Dispose()
Catch myerror As MySqlException
'MessageBox.Show(myerror.Message, "Error Connecting to Database", MessageBoxButtons.OK, MessageBoxIcon.Error)
Catch myerror As System.Exception
'MessageBox.Show(myerror.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If ticker <> "" Then
ToolStripStatusLabel1.Text = "Online"
ToolStripStatusLabel1.ForeColor = Color.Green
ToolStripStatusLabel1.Visible = Not (ToolStripStatusLabel1.Visible)
Else
ToolStripStatusLabel1.Text = "Offline"
ToolStripStatusLabel1.ForeColor = Color.Red
ToolStripStatusLabel1.Visible = Not (ToolStripStatusLabel1.Visible)
End If
End Try
End Sub |
Partager