C#Sqlite ExecuteReader最大返回值

Aid*_*les 5 c# sql sqlite

可以返回的最大行数是ExecuteReader多少?我在表中有67行,它只返回前20行.

这是我的一个来源:

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();
Run Code Online (Sandbox Code Playgroud)

当然,不在while循环中的值在别处定义.

Osa*_*tta 3

尝试像下面这样编辑您的代码:

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();
Run Code Online (Sandbox Code Playgroud)

删除 Value4 和 Value5 或为其指定默认值