
mickvdv
By: a guest on
Jun 3rd, 2009 | syntax:
C# | size: 2.39 KB | hits: 48 | expires: Never
using System;
using System.IO;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Threading;
namespace MySQLChecker
{
class MainClass
{
public static void Main(string[] args)
{
// LAAD DE CONFIG FILE
StreamReader file
= new StreamReader
("/home/mickvdv/Projects/MySQL-Checker/MySQL-Checker/configfile.cfg");
string line = file.ReadLine();
string server = line.Replace("server = ", "");
line = file.ReadLine();
string database = line.Replace("database = ", "");
line = file.ReadLine();
string user = line.Replace("user = ", "");
line = file.ReadLine();
string password = line.Replace("password = ", "");
line = file.ReadLine();
string table = line.Replace("table = ", "");
// debug!!
//string text = server +" "+ database +" "+ user +" "+password+" "+table;
//MessageBox.Show(text);
// LAAD DE OUDE WAARDE
file
= new StreamReader
("/home/mickvdv/Projects/MySQL-Checker/MySQL-Checker/oldvalue.tmp");
line = file.ReadLine();
int oldValue = Convert.ToInt16(line);
int n = oldValue;
//Debug!!
//text = Convert.ToString(oldValue);
//MessageBox.Show(text);
// VERBIND MET MYSQL
string MyConString = "SERVER="+server+";" +"DATABASE="+database+";" +"UID="+user+";" +"PASSWORD="+password+";";
MySqlConnection connection
= new MySqlConnection
(MyConString
);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
string output;
// Temporairly
string outputText = "Succesfully STARTED MySQL CHECKER";
MessageBox.Show(outputText, "SUCCES",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
form1.Show();
form1.Hide();
while (true)
{
command.CommandText = "select count(*) from "+table;
connection.Open();
Reader = command.ExecuteReader();
Reader.Read();
output = Reader.GetValue(0).ToString();
n = Convert.ToInt16(output);
if (n > oldValue){
MessageBox.Show(Convert.ToString(n), "New Table Entry",
MessageBoxButtons.OK,
MessageBoxIcon.Information);
form1.Show();
form1.Hide();
oldValue = n;
}
connection.Close();
Thread.Sleep(100);
}
}
}
}