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());

}

转载于:https://www.cnblogs.com/hunpo/archive/2013/02/06/2907975.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值