问题描述
SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);adapter.InsertCommand=builder.GetInsertCommand();DataRowrow=table.NewRow();row[0]=textBoxStuno.Text;row[1]=textBoxName.Text;row[2]=sex;row[3]=dateTimePicker1.Text;row[4]=textBoxDept.Text;table.Rows.Add(row);try{adapter.InsertCommand.ExecuteNonQuery();adapter.Update(table);}catch(Exceptionex){MessageBox.Show("插入失败"+ex.Message);}表里插进去了而且能在DataGridView中显示出来,但是数据库还是不能插入adapter.Update(table);这个语句不就是把数据库更新吗??为什么没反应呢
解决方案
解决方案二:
DataRowrow=table.NewRow();row[0]=textBoxStuno.Text;row[1]=textBoxName.Text;row[2]=sex;row[3]=dateTimePicker1.Text;row[4]=textBoxDept.Text;table.Rows.Add(row);try{SqlCommandBuilderbuilder=newSqlCommandBuilder(adapter);adapter.Update(table);}catch(Exceptionex){MessageBox.Show("插入失败"+ex.Message);}这样试试
解决方案三:
引用1楼的回复:
DataRowrow=table.NewRow();row[0]=textBoxStuno.Text;row[1]=textBoxName.Text;row[2]=sex;row[3]=dateTimePicker1.Text;row[4]=textBoxDept.Text;table.Rows.Add(row);……
这样还是不行
解决方案四:
adapter.InsertCommand=builder.GetInsertCommand();这个断点看你的Command是什么
解决方案五:
引用3楼的回复:
adapter.InsertCommand=builder.GetInsertCommand();这个断点看你的Command是什么
晕这个不知道怎么看
解决方案六:
急求各位帮帮忙