private void AddRoles_Click(object sender, EventArgs e) { if (MovieRoleBox.Text == "" || ActorRoleBox.Text == "" || RoleName.Text == "") { RoleStatus.Text = "Missing Inputs"; RoleStatus.ForeColor = System.Drawing.Color.Red; RoleStatus.Show(); MovieRoleBox.SelectedIndex = -1; ActorRoleBox.SelectedIndex = -1; AddRoles.Enabled = false; return; } int MovieID = Convert.ToInt32(((ComboboxItem)MovieRoleBox.SelectedItem).Key); int ActorID = Convert.ToInt32(((ComboboxItem)ActorRoleBox.SelectedItem).Key); String conString = @"Data Source=SHERIF\SQLEXPRESS;Initial Catalog=PopCornia;Persist Security Info=True;User ID=sa;Password=123456"; SqlConnection connection = new SqlConnection(conString); connection.Open(); SqlCommand query = new SqlCommand(); query.CommandText = "INSERT INTO Roles(Movie_ID, Actor_ID, RoleName) VALUES ('" + MovieID + "', '" + ActorID + "', '" + RoleName.Text + "');"; query.Connection = connection; query.CommandType = CommandType.Text; try { query.ExecuteNonQuery(); RoleStatus.Text = "Added!"; RoleStatus.ForeColor = System.Drawing.Color.LimeGreen; RoleStatus.Show(); RoleName.Clear(); } catch (Exception x) { RoleStatus.Text = "Role Already Exist!"; RoleStatus.ForeColor = System.Drawing.Color.Red; RoleStatus.Show(); RoleName.Clear(); } AddRoles.Enabled = false; MovieRoleBox.SelectedIndex = -1; ActorRoleBox.SelectedIndex = -1; updateDropLists(6); }