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
循环来完成什么?