Пример #1
0
        public static void insertion(String logicalName, String description, String valeur)
        {
            MySqlConnection connection = BDUtils.GetDBConnection();

            connection.Open();
            try
            {
                String sql = "insert into Compteur (logicalName,description,valeur) values('" + logicalName + "','" + description + "','" + valeur + "');";

                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = sql;

                int rowCount = cmd.ExecuteNonQuery();

                Console.WriteLine("Row Count affected = " + rowCount);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
                connection = null;
            }


            Console.Read();
        }
Пример #2
0
        public static void  insertionProfile(List <String> colunm, DateTime time)
        {
            String req = "insert into profile(colonne1,colonne2,colonne3,colonne4,date) values('";

            for (int i = 0; i < colunm.Count; i++)
            {
                req += colunm[i] + "', '";
            }


            req += time.ToString("yyyy-MM-dd HH:mm:ss") + "');";

            MySqlConnection connection = BDUtils.GetDBConnection();

            connection.Open();


            try
            {
                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = req;

                int rowCount = cmd.ExecuteNonQuery();

                Console.WriteLine("Row Count affected = " + rowCount);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
                connection = null;
            }

            Console.Read();
        }
Пример #3
0
        public static void CreationTableProfile(List <String> colunm)
        {
            MySqlConnection connection = BDUtils.GetDBConnection();

            connection.Open();
            String req = "Create  Table  IF NOT EXISTS Profile(";

            for (int i = 0; i < colunm.Count; i++)
            {
                req += colunm[i] + " Varchar(50),";
            }
            req += "date DATETIME ); ";

            try
            {
                MySqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = req;

                int rowCount = cmd.ExecuteNonQuery();

                Console.WriteLine("Row Count affected = " + rowCount);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e);
                Console.WriteLine(e.StackTrace);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
                connection = null;
            }

            Console.Read();
        }