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();
}
此代码更新为组合框提供数据的表。在重新启动应用程序之前,它会很好地更新数据库,但不会更新应用程序下拉列表。任何帮助将不胜感激。
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";
这是与组合框有任何关系的代码。