关于Datagridview向数据库添加数据的问题!
求指教:为什么以下代码,当datagridview有N行数据时,它只添加一行数据到数据库里,我看不出有什么错漏,其中Base_Class.DataBase.Insert(sql);是一个添加方法this.dataGridView1.AllowUserToAddRows = false;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
string sql = "insert into tb_DanJu (DanJuHao,DanWeiQuanCheng,DanWeiLeiBie,YuanShiDanHao,ShiJian,CaiWuNianYue,KuFang,JingShouRen,ZhiDanRen,DanJuBeiZhu) values('" + textBox1.Text.Trim() + "','" + textBox4.Text.Trim() + "','" + label9.Text.Trim() + "','" + textBox2.Text.Trim() + "','" + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "','" + Base_Class.BaseInfo.dangqianriqi + "','" + comboBox3.Text.Trim() + "','" + comboBox1.Text.Trim() + "','" + textBox3.Text.Trim() + "','" + "无" + "')";
Base_Class.DataBase.Insert(sql);
}