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

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM