I've created the table and put several rows into it. Is there a way to parse my own objects from table?
class Human
{
string name;
int age;
public Human(string name, int age)
{
this.name = name;
this.age = age;
}
}
-- create table
string sql = "create table human (name varchar(20), age int)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
-- insert sample data
string sql = "insert into human (name, age) values ('John', 20)";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
-- get the data back from that table
string sql = "select * from human";
command = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
Now how do I parse a Human instance from my reader?
.ExecuteQuery()after you've already called.EXecuteReader! Just one call, please - and since you want to get back the result set, you need.ExecuteReader()....