using (SqlConnection con = new SqlConnection(cons))
{
con.Open();
using (SqlCommand com = new SqlCommand("INSERT INTO Dealers (DealerId,DealerName) values (NEXT VALUE FOR Dealers_DealerId_SEQ,@dname)", con))
{
com.Parameters.AddWithValue("@dname", this.ComboText.Text.ToString());
com.ExecuteNonQuery();
}
con.Close();
}
このコードは、comboxにデータを提供するテーブルを更新します。データベースは適切に更新されますが、アプリケーションが再起動されるまでアプリケーションのドロップダウンは更新されません。どんな助けでもありがたいです。
this.Dealers.DataSource = this.dealersBindingSource; this.Dealers.DisplayMember = "DealerName"; this.Dealers.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.Dealers.Name = "Dealers"; this.Dealers.Size = new System.Drawing.Size(121, 21); this.Dealers.ValueMember = "DealerName";
これは、コンボボックスと関係のあるコードです。