c#新手,我正在尝试将新记录保存到数据库表'ProductTbl‘中。该程序首先运行具有多个输入的windows表单,即描述、价格、类别和图像。然后单击保存按钮,这应该会将新记录保存到表中。下面是savebtn点击代码。
private void btnSave_Click(object sender, EventArgs e)
{
ProductTbl product = new ProductTbl();
product.Description = txtDescription.Text;
product.Price = decimal.Parse(txtPrice.Text);
product.Image = byteBLOBData;
product.ProductType = (int)cboCategory.SelectedValue;
cse.AddToProductTbl(product);
cse.SaveChanges();
MessageBox.Show("Record Saved");
}在cse.AddToProductTbl(产品);标记之后,是数据库上下文中的这段代码。
internal void AddToProductTbl(ProductTbl product)
{
throw new NotImplementedException();
}我不断地收到同样的错误;
System.NotImplementedException: 'The method or operation is not implemented.'任何帮助都会很感激,
提前谢谢你,雅各布
发布于 2021-05-15 10:38:15
是的,您没有实现"AddToProductTbl(ProductTbl产品)“方法。实现该方法。
internal void AddToProductTbl(ProductTbl product)
{
//implementation for actually adding product to the product table
}确保还实现了"SaveChanges()“方法
https://stackoverflow.com/questions/67542790
复制相似问题