public void Login(string nomeUsuario, string senha) { //DataSet ds = new DataSet(); try { this.conn = new NpgsqlConnection(this.connString); //Abra a conexão com o PgSQL this.conn.Open(); string buscar = String.Format("Select id, coalesce(tipo ,2) from usuario where nome_usuario = '{0}' and senha = '{1}'", nomeUsuario, senha); using (NpgsqlCommand pgsqlcommand = new NpgsqlCommand(buscar, this.conn)) { NpgsqlDataReader dr = pgsqlcommand.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { AutenticacaoCliente.login(dr.GetInt32(0), dr.GetInt32(1)); } } else { Console.WriteLine("Não funcionou!"); } } } catch (NpgsqlException ex) { throw ex; } catch (Exception ex) { throw ex; } finally { this.conn.Close(); } }