using System;
using System.Data.Odbc;

namespace GameServer
{
    class cSQL
    {
        public OdbcConnection SQLConn;

        public void ConnectSQL()
        {
            try
            {
                SQLConn = new OdbcConnection("DSN=" + Program.ConfigClass.DSN_Login + ";");
                SQLConn.Open();

                if (SQLConn.State == System.Data.ConnectionState.Open)
                {
                    new cLog(C.MSG_SUCCESS, "Connected to the Database");
                }
            }
            catch
            {
                new cLog(C.MSG_ERROR, "Connecting to the SQL Server failed!");
                Console.Read();
            }

            Program.ServerClass.SetUpHandlers();
            Program.ISC.ConnectISC();

        }

        public bool runSQL(string Syntax)
        {
            try
            {
                OdbcCommand SqlCmd = new OdbcCommand(Syntax, SQLConn);
                SqlCmd.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}