查询winform

时间:2016-08-25 20:57:16

标签: c# winforms

我有一个带有DataGridView数据库的窗体到单个表。在页面加载时,我运行一个查询以返回DataGrid视图中的单行:

   private void SQL__Edit_Load(object sender, EventArgs e)
    {

        // TODO: This line of code loads data into the 'sQLInfrastructureADD_EDIT.SQLInfrastructure' table. You can move, or remove it, as needed.
        this.sQLInfrastructureTableAdapter.Fill(this.sQLInfrastructureADD_EDIT.SQLInfrastructure);

        {
            SqlDataAdapter sba = new SqlDataAdapter("Select * from dbo.SQLInfrastructure WHERE [Instance] LIKE  '" + label1.Text + "%'", connn);

            System.Data.DataTable data = new System.Data.DataTable();
            sba.Fill(data);
            sQLInfrastructureDataGridView.DataSource = data;
        }



    }

然后我有一个带有保存按钮的绑定导航器:

 private void sQLInfrastructureBindingNavigatorSaveItem_Click(object sender,  EventArgs e)
    {
        this.Validate();
        this.sQLInfrastructureBindingSource.EndEdit();
        this.tableAdapterManager.UpdateAll(this.sQLInfrastructureADD_EDIT);

    }

当我删除查询时,整个表加载并使用绑定导航器保存,当我将查询添加到仅加载需要编辑的单行时,它不会将更改保存到数据库。请指导我如何运行此查询并使用绑定导航器从结果中保存对数据库的更改。

0 个答案:

没有答案