private void btnsave_Click(object sender, EventArgs e) { if(comboslm.Text == "") { MessageBox.Show("Please Select Salesman Name"); comboslm.Focus(); } else if(slmname.Text=="" || slmname.Text==!char.IsWhiteSpace(e.KeyChar)) (Here only redline it is showing.So unable to render also) { MessageBox.Show("Empty Salesman Name Not Accepted"); slmname.Focus(); } else if (combosmancode.Text == "") { MessageBox.Show("Select Record Key Number"); combosmancode.Focus(); } else { SqlConnection con = new SqlConnection(@"Data Source=M2\SQL2016;Initial Catalog=inventoryDB;Integrated Security=True"); con.Open(); SqlCommand cmd = new SqlCommand("UPDATE smanDB SET smaname=@label2 WHERE smancode=@label4", con); cmd.Parameters.Add("@label2", slmname.Text); cmd.Parameters.Add("@label4", combosmancode.GetItemText(combosmancode.SelectedItem)); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Updated Successfully"); /* combosmancode.SelectedIndex = -1; comboslm.SelectedIndex = -1; slmname.Text = ""; comboslm.Focus();*/ con = new SqlConnection(@"Data Source=M2\SQL2016;Initial Catalog=inventoryDB;Integrated Security=True"); con.Open(); string query = "SELECT smaname FROM smanDB"; string que = "SELECT smancode FROM smanDB"; SqlDataAdapter da = new SqlDataAdapter(query, con); SqlDataAdapter sda = new SqlDataAdapter(que, con); DataSet ds = new DataSet(); DataSet sds = new DataSet(); da.Fill(ds, "smanDB"); sda.Fill(sds, "smanDB"); comboslm.DisplayMember = "smaname"; comboslm.ValueMember = "smaname"; comboslm.DataSource = ds.Tables["smanDB"]; combosmancode.DisplayMember = "smancode"; combosmancode.ValueMember = "smancode"; combosmancode.DataSource = sds.Tables["smanDB"]; combosmancode.SelectedIndex = -1; comboslm.SelectedIndex = -1; slmname.Text = ""; con.Close();
comboslm
combosmancode
slmname
else if(slmname.Text=="" || slmname.Text==!char.IsWhiteSpace(e.KeyChar))
slmname.Text
!char.IsWhiteSpace(e.KeyChar)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)