C # Sqlite ExecuteReader maximum return

What is the maximum number of rows that can be returned ExecuteReader? I have 67 rows in a table and it only returns the first 20.

Here is part of my source:

SQLiteConnection sDBConnection = new SQLiteConnection("Data Source=Database.ddb;Version=3");
sDBConnection.Open();
string sqlCom = "SELECT * FROM Table1";
SQLiteCommand scdCommand = new SQLiteCommand(sqlCom, sDBConnection);
SQLiteDataReader reader = scdCommand.ExecuteReader();

while(reader.Read())
{
    string Value1 = (string)reader["Col1"];
    bool Value2 = true;
    string Value3 = (string)reader["Col2"];
    object[] row = { Value1, Value2, Value3, Value4, Value5 };
    DataGridView1.Rows.Add(row);
}

reader.Close();
sDBConnection.Close();

Of course, values ​​that are not part of the while loop are defined elsewhere.

+4
source share
1 answer

Try changing your code as shown below:

SQLiteConnection sDBConnection = new SQLiteConnection("Data Source=Database.ddb;Version=3");
sDBConnection.Open();
string sqlCom = "SELECT * FROM Table1";
SQLiteCommand scdCommand = new SQLiteCommand(sqlCom, sDBConnection);
SQLiteDataReader reader = scdCommand.ExecuteReader();

while(reader.Read())
{
string Value1 = reader["Col1"] != null ? Convert.ToString(reader["Col1"]) : string.Empty;
bool Value2 = true;
string Value3 = reader["Col2"] != null ? Convert.ToString(reader["Col2"]) : string.Empty;
object[] row = { Value1, Value2, Value3 };
DataGridView1.Rows.Add(row);
}

reader.Close();
sDBConnection.Close();

remove Value4 and Value5 or assign a default value

+1
source

All Articles