挿入または更新されたデータグリッドビューで直ちにデータを表示する方法。私は、挿入または更新後に更新されたDataGridviewを表示する方法
private void UpdateDebtbutton_Click(object sender, EventArgs e) { SqlConnection conn = ForConnection(); conn.Open(); using (conn) { if (paytextBox.Text != "") { SqlCommand cmd = new SqlCommand("spdebth", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id", SqlDbType.Int).Value =customerIDTextBox.Text.ToString(); cmd.Parameters.Add("@text", SqlDbType.Int).Value = paytextBox.Text.ToString(); cmd.ExecuteNonQuery(); MessageBox.Show("Record updated"); spSelectAllCustomerDataGridView.Update(); spSelectAllCustomerDataGridView.Refresh(); conn.Close(); } } }
データソースを再度設定します。 – Berkay
@Berkay DatatGridViewのDataTableを使用して –
を使用していただきありがとうございます。あなたはdataTable.AcceptChanges()を試しましたか? – JohnG