【发布时间】:2015-06-02 12:53:30
【问题描述】:
我正在创建一个简单的员工目录程序,并且我正在制作它以便用户可以更新目录。但是,当前将数据添加到 DataGridView 时,它不会保存到数据库中。我知道需要this.staffTableAdapter.Update(this.dBDataSet1.Staff);,它在我的程序中,如下所示。
我只是不确定我目前缺少什么,如果有人可以帮助我,我将非常感激。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StaffDirectory
{
public partial class Administration : Form
{
public Administration()
{
InitializeComponent();
}
private void staffBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.staffBindingSource.EndEdit();
this.staffTableAdapter.Update(this.dBDataSet1.Staff);
}
private void Administration_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dBDataSet1.Staff' table. You can move, or remove it, as needed.
this.staffTableAdapter.Fill(this.dBDataSet1.Staff);
}
}
}
【问题讨论】:
-
那里没有例外?
-
有时您可能会使用数据库的副本。确保你不工作。您可以通过数据库的属性来检查它。我不确定你是否做到了。
-
我已经从我的数据库中创建了一个数据集,在这种情况下“whit”是什么意思?
标签: c# database datagridview insert sql-insert