private void btnSave_Click(object sender, EventArgs e)
{
DialogResult result;
result = MessageBox.Show("确定","操作提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
this.productsTableAdapter.Update(this.superMarketDataSet);
}
}
新手。C#2005软件
很简单的一个练习的例子,按下按钮就应该保存。现在的现象是如果在下面新建一行能够保存。如果是在原数据修改后家就会在【this.productsTableAdapter.Update(this.superMarketDataSet);】这一行出现中断。书上写:因为程序自动生成DataSet和DataAdapter,所以不需要手动创建SqlCommandBuilder
{
DialogResult result;
result = MessageBox.Show("确定","操作提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
this.productsTableAdapter.Update(this.superMarketDataSet);
}
}
新手。C#2005软件
很简单的一个练习的例子,按下按钮就应该保存。现在的现象是如果在下面新建一行能够保存。如果是在原数据修改后家就会在【this.productsTableAdapter.Update(this.superMarketDataSet);】这一行出现中断。书上写:因为程序自动生成DataSet和DataAdapter,所以不需要手动创建SqlCommandBuilder
这句是什么意思看不懂,你到底要实现什么功能呀,是想吧dataGridView的内容保存到哪里呀?
design生成的代码如下。
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button1;
private SuperMarketDataSet superMarketDataSet;
private System.Windows.Forms.BindingSource productsBindingSource;
private WindowsApplication1.SuperMarketDataSetTableAdapters.productsTableAdapter productsTableAdapter;
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn productnameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn barcodeDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn amountDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn priceDataGridViewTextBoxColumn;
private System.Windows.Forms.Button btnSave;