SQLite query returns no rows
<p>I am trying to get a simple SQLite database working. I'm using the official SQLite extension for C# and I'm using DataGrip from IntelliJ to verify the data is there, yet my C# program doesn't get any results. </p>

<p>This is the code that executes the query:</p>

<pre><code>SQLiteConnection connection = new SQLiteConnection(DbDsn);

User user = new User();

using (connection)
{
    connection.Open();

    string sql = "SELECT * FROM user WHERE username = @username ;";
    SQLiteCommand command = new SQLiteCommand(sql, connection);
    command.Prepare();
    command.Parameters.AddWithValue("@username", username);

    SQLiteDataReader reader = command.ExecuteReader();

    if (reader.Read())
    {
        user.Id = (int) reader["id"];
        user.Username = reader["username"] as string;
        user.Password = reader["password"] as string;
        user.Name = reader["name"] as string;
        user.LastName = reader["last_name"] as string;
        user.Type = (UserTypes) reader["type"];
    }
    else
    {
        throw new ObjectNotFoundException();
    }
    connection.Close();
}
</code></pre>

<p>And this is the result of a simple <code>Select * From user;</code> query on the user table (done on DataGrip):</p>

<pre><code>id  username    passw…  name    last_name   type
1   managertest oAWpW…  BENJAMIN ARIEL  NAVA MARTINEZ   1
2   clerktest   iRYMz…  EMPLEADO    PRUEBA  0
</code></pre>

<p>As you can see, the records are there (an I've verified that the query is being performed on the exact same file), however, the C# program seems to skip the <code>if</code> statement (because read returns <code>false</code>) as if there were no rows in the database, what is the problem here?</p>