Answer the question
In order to leave comments, you need to log in
How to add specific row to MySqlDataReader?
There is a table with one column.
I need to move it to an array.
How I am trying to do this:
string[] botusers = new string[0];
MySqlDataReader reader = findCommand.ExecuteReader();
while (reader.Read())
{
for (var i = 0; i < reader.FieldCount; i++)
{
Array.Resize(ref botusers, botusers.Length + 1);
botusers[i] = /*Как добавить строку под номером i*/;
}
}
Answer the question
In order to leave comments, you need to log in
Why is it so difficult ... If I understand you correctly, then this is what you need.
var botusers = new List<string>();
using(var reader = findCommand.ExecuteReader())
{
while(reader.Read())
{
botusers.Add(reader.GetString(1));
}
}
var botusers = new List<string>();
using(var reader = await findCommand.ExecuteReaderAsync())
{
while(await reader.ReadAsync())
{
botusers.Add(reader.GetString(1));
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question