Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Sqlite ExecuteReader maximum return

Tags:

c#

sql

sqlite

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.

like image 875
Aiden Miles Avatar asked Oct 31 '22 07:10

Aiden Miles


1 Answers

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

like image 125
Osama AbuSitta Avatar answered Nov 12 '22 22:11

Osama AbuSitta