private void btn_login_Click(object sender, EventArgs e) { try { DataTable dt = Login.GetData("select * from tblaccounts where username = '******' and password = '******'"); if (dt.Rows.Count > 0) { formmain main = new formmain(txtbox_Username.Text, dt.Rows[0].Field <string>("usertype"), txtbox_Password.Text); formregistration reg = new formregistration("", "", "", "add", ""); main.Show(); reg.Close(); this.Hide(); } else { MessageBox.Show("Incorrect username or password or account is inactive", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }