请大伙看看这个鬼问题
con = new System.Data.OleDb.OleDbConnection(sqlconnectionstr);con.Open();
cmd = new System.Data.OleDb.OleDbCommand("select * from accounts", con);
dd = new System.Data.OleDb.OleDbDataAdapter(, con);
ds = new DataSet();
dd.Fill(ds, "accounts");
dataGridView1.DataSource = ds.Tables[0].DefaultView;
dataGridView1.Columns[0].HeaderCell.Value = "账务编码";
dataGridView1.Columns[1].HeaderCell.Value = "银行编码";
dataGridView1.Columns[2].HeaderCell.Value = "员工编码";
dataGridView1.Columns[3].HeaderCell.Value = "账务大类编码";
dataGridView1.Columns[4].HeaderCell.Value = "账务小类编码";
dataGridView1.Columns[5].HeaderCell.Value = "账务类型";
dataGridView1.Columns[6].HeaderCell.Value = "金额";
dataGridView1.Columns[7].HeaderCell.Value = "账务日期";
dataGridView1.Columns[8].HeaderCell.Value = "备注";
// MessageBox.Show(this.dataGridView1["payments", 0].Value.ToString());
for (int k = 0; k < ds.Tables[0].Rows.Count; k++)
{
if (this.dataGridView1.Rows[k]["payments"].ToString() == "收入")//运行时这个给了提示未将对象引用设置到对象的实例。
sumin += Convert.ToDouble(this.dataGridView1["price", k].Value.ToString());
else
sumout += Convert.ToDouble(this.dataGridView1["price", k].Value.ToString());
}
this.label9.Text = Convert.ToString(sumin - sumout);
this.label10.Text = Convert.ToString(sumin);
this.label11.Text = Convert.ToString(sumout);