Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1447

Fetching Multiple Rows (no replies)

$
0
0
Hello :)

I'm having this stupid problem and I can't fix it. I've tried anyway I could and it didnt work. So, i'm seeking help.

I got this exemple table

id | status | params
1 | 2 | test=test
1 | 10 |
1 | 5 | test=test1

I want to get all those rows and fields, and tried like this:

public List<MySqlDataReader> t = new List<MySqlDataReader>();

public void readt()
{
foreach (MySqlDataReader val in t)
{
Console.WriteLine(val["status"]);
}
}

public void test()
{

if (mycon.State != ConnectionState.Open) Connect();
MySqlCommand sql_query = new MySqlCommand(Query, mycon);

fields = sql_query.ExecuteReader();

while (fields.Read())
{
t.Add(fields);
}
}

But when I called "readt", I got

2
2
2

instead of

2
10
5

Why is my script only getting one row, and not all?

Thanks

Viewing all articles
Browse latest Browse all 1447

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>