There is a database with a column of type CHAR and a variable string[] It is necessary to output data from the column to a variable. Connecting with the following code

 MySqlConnection connection = new MySqlConnection(connectionDate); MySqlCommand Query = new MySqlCommand(); // С помощью этого объекта выполняются запросы к БД Query.Connection = connection; // Присвоим объекту только что созданное соединение try { connection.Open(); MessageBox.Show("Соединение установлено!"); } //здесь нужен код для вывода данных connection.Close(); 

    1 answer 1

    Object that refers to the context, thrust in the foreach and in the loop, execute:

    List<string> str = new List<string>(); string[] str2; foreach(var record in contextObject){ str.Add(record.твойСтолбец); } string[] str2 = new string[str.Count]; for(int i=0;i != str.Count;i++){ str2[i]=str[i]; }
    • Added connection code. I can not understand what object to add. (PS I understand the whole nonsense of the question, but the deadlines are tight ((And maybe someone will be useful in the raging.) - Zhenya Vedenin
    • one
      stackoverflow.com/questions/25651318/… - There’s a while in the answer. Try working with rdr from the answer. - Andryxa