예제 #1
0
        /// <summary>
        /// Same, but only one parameter
        /// </summary>
        /// <param name="query"></param>
        /// <param name="parameter"></param>
        public void Query(string query, MySqlParameter parameter)
        {
            MySqlParameters parameters = new MySqlParameters();

            parameters.AddParameter(parameter);
            Query(query, parameters);
        }
예제 #2
0
        public void Query(string query, MySqlParameters parameters)
        {
            using (var mysqlConn = new MySqlConnection())
            {
                if (query.Contains("SELECT"))
                {
                    throw new Exception("WRONG TYPE OF SQL QUERY, NEED INSERT / UPDATE / DELETE");
                }
                lock (threadLock)
                {
                    mysqlConn.ConnectionString = mysqlCSB.ConnectionString;
                    mysqlConn.Open();
                    MySqlCommand com = new MySqlCommand(@query, mysqlConn);


                    foreach (var param in parameters)
                    {
                        com.Parameters.Add(param);
                    }


                    MySqlDataReader dataReader = com.ExecuteReader();
                    dataReader.Read();
                    dataReader.Close();
                }
            }
        }