Beispiel #1
0
        public static DataTable ExecutaFuncSelect(string funcao, string cpf)
        {
            using (SqlConnection conexao = ConexaoDAO.GetConexao())
            {
                string sql = $"select * from {funcao}('{cpf.Trim()}')";

                using (SqlDataAdapter adapter = new SqlDataAdapter(sql, conexao))
                {
                    DataTable tabela = new DataTable();
                    adapter.Fill(tabela);
                    conexao.Close();
                    return(tabela);
                }
            }
        }
Beispiel #2
0
        public static void ExecutaProc(string nomeProc, SqlParameter[] parametros)
        {
            using (SqlConnection connection = ConexaoDAO.GetConexao())
            {
                using (SqlCommand command = new SqlCommand(nomeProc, connection))
                {
                    if (parametros != null)
                    {
                        command.Parameters.AddRange(parametros);
                    }

                    command.CommandType = CommandType.StoredProcedure;

                    command.ExecuteNonQuery();
                }

                connection.Close();
            }
        }
Beispiel #3
0
        //Conexoes realizadas com PROCEDURES
        public static DataTable ExecutaProcSelect(string nomeProc, SqlParameter[] parametros)
        {
            using (SqlConnection connection = ConexaoDAO.GetConexao())
            {
                using (SqlDataAdapter adapter = new SqlDataAdapter(nomeProc, connection))
                {
                    if (parametros != null)
                    {
                        adapter.SelectCommand.Parameters.AddRange(parametros);
                    }

                    adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

                    DataTable table = new DataTable();
                    adapter.Fill(table);
                    connection.Close();
                    return(table);
                }
            }
        }