我搜索并搜索购买我无法找到解决方案 这是我的代码
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();
}
}
}
我需要做什么,如果我离开这一行
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();
}
不起作用:&#39;(
什么病了,请帮助我答案 0 :(得分:0)
好的家伙我最终找到了解决方案:D
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();
}