예제 #1
0
 protected DataTable ListarTabela()
 {
     using (SqlConnection cx = ConexaoBD.GetConexao())
     {
         string sql = "sp_Listar" + ProcedureName();
         return(Metodos.ExecutaSelect(sql, null));
     }
 }
예제 #2
0
 /// <summary>
 /// Método para consultar 1 registro
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public PadraoVO Consulta(int id)
 {
     using (SqlConnection cx = ConexaoBD.GetConexao())
     {
         string         sql        = "sp_Consulta" + ProcedureName();
         SqlParameter[] parametros = { new SqlParameter("id", id) };
         return(ExecutaSqlLocal(sql, parametros));
     }
 }
예제 #3
0
 public static void ExecutaSQL(string sql, SqlParameter[] parametros)
 {
     using (SqlConnection conn = ConexaoBD.GetConexao())
     {
         SqlCommand comando = new SqlCommand(sql, conn);
         comando.Parameters.AddRange(parametros);
         comando.CommandType = CommandType.StoredProcedure;
         comando.ExecuteNonQuery();
     }
 }
예제 #4
0
 public static DataTable ExecutaFunction(string sql, SqlParameter[] parametros)
 {
     using (SqlConnection conn = ConexaoBD.GetConexao())
     {
         using (SqlDataAdapter adapter = new SqlDataAdapter(sql, conn))
         {
             if (parametros != null)
             {
                 adapter.SelectCommand.Parameters.AddRange(parametros);
             }
             adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
             DataTable tabela = new DataTable();
             adapter.Fill(tabela);
             return(tabela);
         }
     }
 }