private void button1_Click(object sender, EventArgs e) { string connectionstring = ConfigurationManager.ConnectionStrings["mydb"].ConnectionString; SqlConnection conn = new SqlConnection(connectionstring); SqlCommand cmd = new SqlCommand("select * from login where NicNo= '" + nicMaskedTextBox1.Text + "'", conn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(ds); int i = ds.Tables[0].Rows.Count; if (i > 0) { MessageBox.Show("card h "); this.Close(); loginForm lf = new loginForm(); lf.Show(); } else { MessageBox.Show(nicMaskedTextBox1.Text + " NicNo is Not Exists.\nPlease Enter Correct NicNo ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); nicMaskedTextBox1.Clear(); nicMaskedTextBox1.Focus(); } }