public bool SLogin() { bool flag = false; DbMySqlHelper mySqlHelper = new DbMySqlHelper(); string userString = userName.Text.Trim(); string pwdString = passWord.Text.Trim(); //创建sql try { string sql = string.Format("select * from ec_user where username = '******' and passwd = '{1}'", userString, pwdString); DataTable mysqlData = mySqlHelper.getMySqlRead(sql); if (mysqlData.Rows.Count >= 1) { flag = true; } } catch (Exception ex) { MessageBox.Show("发生异常 " + ex.Message); flag = false; } return(flag); }