private void metroButtonLogin_Click(object sender, EventArgs e)
{
try
{
//Your insert code here
DataSet1TableAdapters.UsersTableAdapter userAda = new DataSet1TableAdapters.UsersTableAdapter();
DataTable dt = userAda.GetDataByUserAndPass(metroTextBoxUser.Text, metroTextBoxPass.Text);
if (dt.Rows.Count > 0)
{
//valid
MessageBox.Show("Login Ok");
UserID = int.Parse(dt.Rows[0]["UserID"].ToString());
loginFlag = true;
}
else
{
// not valid
MessageBox.Show("Access Denied");
loginFlag = false;
}
Close();
}// above is your origine code
catch (System.Data.SqlClient.SqlException sqlException)
{
System.Windows.Forms.MessageBox.Show(sqlException.Message);
}
}