Update to database version 3.

This commit is contained in:
2018-04-15 17:51:07 +01:00
parent 3ded57a24d
commit ae10cca33a
51 changed files with 1278 additions and 1214 deletions

View File

@@ -75,6 +75,7 @@ namespace Cicm.Database
$"server={server};user={user};database={database};port={port};password={password}";
connection = new MySqlConnection(connectionString);
connection.Open();
Operations = new Operations(connection, this);
@@ -120,6 +121,7 @@ namespace Cicm.Database
$"server={server};user={user};database={database};port={port};password={password}";
connection = new MySqlConnection(connectionString);
connection.Open();
IDbCommand command = connection.CreateCommand();
command.CommandText = $"CREATE DATABASE `{database}`;";
@@ -154,6 +156,21 @@ namespace Cicm.Database
return new MySqlDataAdapter();
}
public bool TableExists(string tableName)
{
MySqlCommand cmd = connection.CreateCommand();
cmd.CommandText =
$"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{connection.Database}' AND table_name = '{tableName}'";
MySqlDataReader reader = cmd.ExecuteReader();
reader.Read();
int count = reader.GetInt32(0);
reader.Close();
return count > 0;
}
~Mysql()
{
CloseDb();