What is the best way to populate a List using a SQLite DB. I had been using SQLiteDataAdapter and one of a colleague of mine told me that it is not a great choice.
Asked
Active
Viewed 2,473 times
1 Answers
2
You could use a SqliteDataReader
.
using(SqliteConnection con = new SqliteConnection(cs))
{
con.Open();
string stm = "SELECT ListItem FROM Table";
using (SqliteCommand cmd = new SqliteCommand(stm, con))
{
using (SqliteDataReader rdr = cmd.ExecuteReader())
{
while (rdr.Read())
{
//add items to your list
}
}
}
con.Close();
}
From this article.
The SqliteDataReader is a class used to retrieve data from the database. It is used with the SqliteCommand class to execute an SQL SELECT statement and then access the returned rows. It provides fast, forward-only, read-only access to query results. It is the most efficient way to retrieve data from tables.
This comparison is for SQL Server, but the result is the same: SqlDataAdapter vs SqlDataReader
Another comparison chart here from this article.

Community
- 1
- 1

Christian Phillips
- 18,399
- 8
- 53
- 82
-
Thank you for the answer. Do you know why it is not that great? – Doro Jul 29 '14 at 14:28
-
1@doro, I just added a comparison to the answer. – Christian Phillips Jul 29 '14 at 14:31