C#使用Tableadapter进行update,Insert的操作

需要注意的是,调试时更新的数据库是 debug目录下的数据库;

private void updatebutton_Click(object sender, EventArgs e)
{
this.book_infoBindingSource.EndEdit();
this.book_infoTableAdapter.Update(this.bookstoreDataSet.book_info);
}

private void insertbutton_Click(object sender, EventArgs e)
{

//在datagridview里直接添加,选择datagridview的当前行的各个单元格数据进行更新,调试时,更新的是项目的debug目录下的数据库
this.book_infoTableAdapter.Insert(this.book_infoDataGridView.CurrentRow.Cells[0].Value.ToString(),this.book_infoDataGridView.CurrentRow.Cells[1].Value.ToString(), this.book_infoDataGridView.CurrentRow.Cells[2].Value.ToString(), this.book_infoDataGridView.CurrentRow.Cells[3].Value.ToString(), Convert.ToDateTime(this.book_infoDataGridView.CurrentRow.Cells[4].Value),this.book_infoDataGridView.CurrentRow.Cells[5].Value.ToString(), this.book_infoDataGridView.CurrentRow.Cells[6].Value.ToString());

}

posted @ 2013-02-06 18:06  绝对菜鸟  阅读(7605)  评论(1编辑  收藏  举报