I just started using SQLite with C#. I know how to pull a query to order the table by currency. I just don't know how to loop it for each row and write it into a list.
The table is called channel. The query will order by currency and return the top 10 rows, but only pull data from user column.
String sql = "SELECT user FROM '" + channel + "' ORDER BY currency DESC LIMIT 10";
What I came up with so far. If anyone can help me, it will be appreciated. Still new to C# and SQLite - trying to teach myself.
public string top10()
{
string[] toplist = new string[10];
int cntr = 0;
String sql = "SELECT user FROM '" + channel + "' ORDER BY currency DESC LIMIT 10";
using (cmd = new SQLiteCommand(sql, myDB))
{
using (SQLiteDataReader r = cmd.ExecuteReader())
{
while (r.HasRows)
{
if (r.Read())
{
toplist[cntr] = r.GetString(1);
cntr++;
}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire