从 TableAdapter 插入后 DataGridView 未更新

DataGridView not updating after an Insert from TableAdapter

在我的 form1 中,我正在插入

tableAdapterManager.BatchTableAdapter.Insert(Int32.Parse(Maxorder) + 10, DateTime.Now, DateTime.Now, Int32.Parse(txtData0.Value.ToString()), 1);

所以它向我的 LocalDb 添加了参数,但随后我转到 form2,它应该在 dataGridView 中显示结果。这个DataGridView 是带有DataSource 的一个View。该视图从不显示 "inserted" 参数,只有在我重新启动应用程序时才会显示。我试过:

v_BatchTableAdapter.Fill(dbSahara.v_Batch);

但我只在打开应用程序之前获取插入的数据。

如果有人能帮助我...在此先感谢。

我"repaired"它这样做:

 private void GetData(string selectCommand)
    {
        try
        {
            // Specify a connection string. Replace the given value with a 
            // valid connection string for a Northwind SQL Server sample
            // database accessible to your system.
            String connectionString =
                "Integrated Security=SSPI;Persist Security Info=False;" +
                "Initial Catalog=Northwind;Data Source=localhost";

            // Create a new data adapter based on the specified query.
            dataAdapter = new SqlDataAdapter(selectCommand, connectionString);

            // Create a command builder to generate SQL update, insert, and
            // delete commands based on selectCommand. These are used to
            // update the database.
            SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

            // Populate a new data table and bind it to the BindingSource.
            DataTable table = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            dataAdapter.Fill(table);
            bindingSource1.DataSource = table;

            // Resize the DataGridView columns to fit the newly loaded content.
            dataGridView1.AutoResizeColumns( 
                DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
        }
        catch (SqlException)
        {
            MessageBox.Show("To run this example, replace the value of the " +
                "connectionString variable with a connection string that is " +
                "valid for your system.");
        }
    }

字体:https://msdn.microsoft.com/es-es/library/vstudio/fbk67b6z(v=vs.100).aspx