如何在 Visual Studio 2015 中提交对本地 SQL 数据库的更改?

How to commit changes to local SQL DB In Visual Studio 2015?

我是使用数据库的新手。我制作了一个简单的表单应用程序来显示此数据 table 但是,我无法将数据导入数据库以便表单显示它。我最初在这里只列出了 1 名员工,他出现在我的申请中。我刚刚将最后 3 名员工添加到此 table 视图中,但如果我 运行 该应用程序,则只会显示原始员工 (id 1)。如何将最后 3 名员工的信息提交到数据库中?我在谷歌上搜索了一些关于此的信息并找到了一个 select * from dbo.EmployeeInfo 查询和 运行 它,它正确显示了员工信息,但它似乎没有用新信息更改数据库。谢谢。

我创建了一个带有 GridView 的表单,并将其与数据源绑定,它向我显示了上面显示的表单中的数据...

添加了一些用于输入的文本框……

下面的代码显示了它如何将数据源与 gridview 绑定,以及如何在按钮单击事件中使用来自文本框的输入永久插入数据

private void Form1_Load(object sender, EventArgs e)
    {
        // using a gridview by binding the dataset with it at form load
        //It creates the table for you with the relevant columns
        //and fills it with this line of code
        this.employeesTableAdapter.Fill(this.practiceDBDataSet.Employees);

    }

    private void btnSubmit_Click(object sender, EventArgs e)
    {
        //on add  user button click
        //I access the tableadpater created by the dataset to be accessed by the gridview
        //the txt.... represents my fields names according to the database
        employeesTableAdapter.Insert(txtName.Text, txtSurname.Text, txtAge.Text, Convert.ToInt32(txtAge.Text));
    }

然后是 txt.... 用于数据库所需的数据,您将从那里获取输入......

我也被卡在这里了。 我所做的是 - 1) 更新了值并更新了最后一个值后,我按了 Enter

这似乎对我有用。 键盘上的输入按钮让生活变得简单。 :)