您的位置:首页 > 编程语言 > C#

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

2013-02-06 18:06 387 查看
需要注意的是,调试时更新的数据库是 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());

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐