Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#-SQLITE和dataGridView1_C#_Sqlite_Datagridview - Fatal编程技术网

c#-SQLITE和dataGridView1

c#-SQLITE和dataGridView1,c#,sqlite,datagridview,C#,Sqlite,Datagridview,我搜索,我搜索,我买,我找不到解决方案 这是我的密码 private void pointage_Load(object sender, EventArgs e) { sql = "SELECT firstname, lastname FROM company"; command = new SQLiteCommand(sql, connectiondb); DataSet1 mydata = new Dat

我搜索,我搜索,我买,我找不到解决方案 这是我的密码

private void pointage_Load(object sender, EventArgs e)
        {
            sql = "SELECT firstname, lastname FROM company";
            command = new SQLiteCommand(sql, connectiondb);
            DataSet1 mydata = new DataSet1();
            SQLiteDataAdapter zz = new SQLiteDataAdapter(sql, connectiondb);
            zz.Fill(mydata.Tables["DataTable1"]);

            int i;
            SQLiteDataReader reader = command.ExecuteReader();
            DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[1].Clone();
            while (reader.Read())
            {
                    for (i = 0; i <= System.Convert.ToUInt32(reader["id"]); i++)
                    {
                        row = this.dataGridView1.Rows[i];
                        row.Cells["Column10"].Value = reader["firstname"].ToString();
                        row.Cells["Column9"].Value = reader["lastname"].ToString();
                    }
            }

        }
 for (i = 0; i <= System.Convert.ToUInt32(reader["id"]); i++)
                         {
                             row = this.dataGridView1.Rows[i];
                             row.Cells["Column10"].Value = reader["firstname"].ToString();
                             row.Cells["Column9"].Value = reader["lastname"].ToString();
                         }
我把它放在

MessageBox.Show(reader["firstname"].ToString());
 for (i = 0; i <= System.Convert.ToUInt32(reader["id"]); i++)
                         {
                             row = this.dataGridView1.Rows[i];
                             row.Cells["Column10"].Value = reader["firstname"].ToString();
                             row.Cells["Column9"].Value = reader["lastname"].ToString();
                         }
那会有用的,但当我这么做的时候

 for (i = 0; i <= System.Convert.ToUInt32(reader["id"]); i++)
                         {
                             row = this.dataGridView1.Rows[i];
                             row.Cells["Column10"].Value = reader["firstname"].ToString();
                             row.Cells["Column9"].Value = reader["lastname"].ToString();
                         }

for(i=0;iok伙计们,最后我找到了解决方案:D

 for (i = 0; i <= System.Convert.ToUInt32(reader["id"]); i++)
                         {
                             row = this.dataGridView1.Rows[i];
                             row.Cells["Column10"].Value = reader["firstname"].ToString();
                             row.Cells["Column9"].Value = reader["lastname"].ToString();
                         }
    while (reader.Read())
    {
        i = System.Convert.ToInt32(reader["id"].ToString());
        dataGridView1.Rows.Add();

        MessageBox.Show(System.Convert.ToString(i));
        DataGridViewRow R = dataGridView1.Rows[i-1];

        R.Cells["Column9"].Value = reader["firstname"].ToString();
        R.Cells["Column10"].Value = reader["lastname"].ToString();

    }
你能详细说明一下“那不起作用”吗?你有例外吗?你想用
for
循环来完成什么?