Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/03/2010, 17:55
Avatar de atak
atak
 
Fecha de Ingreso: julio-2005
Ubicación: Huancayo
Mensajes: 490
Antigüedad: 18 años, 9 meses
Puntos: 5
De acuerdo Consultar por fechainicio, fechafin y un por caso

Hola,

tengo un ejemplo similar a tu problema :

Procedimiento Almacenado:

Código PHP:
create procedure  [dbo].[PedidosPorFecha]
(
    @
FechaInicial datetime,
    @
FechaFinal datetime,
    @
idCliente char(5)
)

as
select  pedidos.IdPedido,FechaPedido,FechaEntregaNombre +' 'Apellidos  as Vendedor,
        
NombreCompañía as cliente, sum(Cantidad*PrecioUnidad) as Total
from pedidos
inner join clientes on pedidos
.idcliente=clientes.idcliente 
inner join empleados on pedidos
.idempleado=empleados.idempleado
inner join 
[detalles de pedidos]
on pedidos.idpedido=[detalles de pedidos].idpedido
where FechaPedido between 
@FechaInicial and @FechaFinal
and Pedidos.idcliente=@idCliente 

Codigo en VB.NET


Código PHP:
 Public Shared Function ListarPedidosPorFecha(ByVal fechainicial As DateByVal fechafinal As DateByVal idcliente As String) As DataTable
        Dim cn 
As New SqlConnection(Conexion.LeerCadenaConexion)
        
Dim cmd As New SqlCommand("pedidosPorFecha"cn)
        
cmd.CommandType CommandType.StoredProcedure
        cmd
.Parameters.AddWithValue("@fechainicial"fechainicial)
        
cmd.Parameters.AddWithValue("@fechafinal"fechafinal)
        
cmd.Parameters.AddWithValue("@idcliente"idcliente)
        Try
            
Dim da As New SqlDataAdapter(cmd)
            
Dim tb As New DataTable
            da
.Fill(tb)
            Return 
tb
            da
.Dispose()
        Catch 
ex As Exception
            
Throw ex
        Finally
            cn
.Dispose()
            
cmd.Dispose()
        
End Try 

Saludos
Espero te ayude ...
__________________
. .: El mejor Inicio :. .