Beispiel #1
0
        public static bool CheckLoginOld(string login, string password)
        {
            try
            {
                using (SqlConnection connection = DBSQLServerUtils.GetDBConnection())
                {
                    try
                    {
                        connection.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);//Вывод в лог текст исключения
                        throw;
                    }
                    SqlCommand command = connection.CreateCommand();
                    command = new SqlCommand(@"SELECT [Password] FROM [StudyDB].[dbo].[Account] WHERE [Login] = '" + login + "'", connection);
                    SqlDataReader reader = command.ExecuteReader();
                    reader.Read();

                    if (password == reader["Password"].ToString())
                    {
                        reader.Close();
                        return(true);
                    }

                    reader.Close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);//Вывод в лог текст исключения
                MessageBox.Show("Ошибка подключения к базе данных!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
        }
Beispiel #2
0
 protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
 {
     optionsBuilder.UseSqlServer(DBSQLServerUtils.GetDBStringConnection());
 }