コード例 #1
0
        /// <summary>
        /// Возвращает список с данными из таблицы
        /// </summary>
        /// <param name="quary">Запрос</param>
        /// <param name="numberReadRow">Номера тех столбцов, с которых будут браться данные </param>
        /// <returns></returns>
        public static List <List <dynamic> > MySqlQuaryOut(string quary, params int[] numberReadRow)
        {
            List <List <dynamic> > arrData = new List <List <dynamic> >();

            OpenConnect(ref mySQLConn);

            MySqlCommand    myCommand = new MySqlCommand(quary, mySQLConn);
            MySqlDataReader MyDataReader;

            MyDataReader = myCommand.ExecuteReader();

            for (int i = 0; i < numberReadRow.Length; i++)
            {
                arrData.Add(new List <dynamic>());
            }

            while (MyDataReader.Read())
            {
                for (int i = 0; i < numberReadRow.Length; i++)
                {
                    if (!MyDataReader.IsDBNull(numberReadRow[i]))
                    {
                        arrData[i].Add(MyDataReader.GetString(numberReadRow[i]));
                    }
                    else
                    {
                        arrData[i].Add("null");
                    }
                }
            }
            mySQLConn.Close();
            return(arrData);
        }