enter image description here enter image description here

MySqlConnection conn = new MySqlConnection(connStr); conn.Open(); string sql = $"select subscribe from dle_users where email = '{textBoxUserEmail.Text}' and password = '{sspass}' "; MySqlCommand command = new MySqlCommand(sql, conn); command.Prepare(); command.ExecuteNonQuery(); if (textBoxUserEmail.Text == (string)command.ExecuteScalar()) { DateTime d1; try { string date = command.ExecuteScalar().ToString(); var client = new TcpClient("time.nist.gov", 13); using (var streamReader = new StreamReader(client.GetStream())) { var response = streamReader.ReadToEnd(); var utcDateTimeString = response.Substring(7, 17); d1 = DateTime.ParseExact(utcDateTimeString, "yy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); } DateTime d2 = Convert.ToDateTime(date); TimeSpan time = d2 - d1; int days = time.Days; if (days > 0) { passlIsPass = true; if (conn != null && conn.State != ConnectionState.Closed) conn.Close(); } if (days < 0) { DialogResult result = MessageBox.Show("Продлите подписку !", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { DialogResult result = MessageBox.Show("Ошибка", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { passlIsPass = false; DialogResult result = MessageBox.Show("Логин или пароль введен неверно", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning); } 
  • @Bulson added screen - Andryukha Raise
  • @Bulson is remove it? - Andryukha Raise
  • @Bulson string date = command.ExecuteScalar (). ToString (); replace it with string date = (string) command.ExecuteScalar () - Andryukha Raise
  • @Bulson I did as you said, but now I always have the same lie and say that the login and password are wrong, although before that everything worked without checking the date! if (textBoxUserEmail.Text == command.ExecuteScalar (). ToString ()) - Andryukha Raise
  • I wrote how to fix the error in the line in which it occurs. And not the logic of your code execution. Feel the difference? - Bulson

0