What is the maximum amount of rows that can be returned by ExecuteReader
? I have some 67 rows in a table and it only returns the first 20.
Here's a piece 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, the values that aren't in the while loop are defined elsewhere.
Try edit your code like 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 give it default value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With