problema con salida de datos
Publicado por juan (55 intervenciones) el 23/06/2009 21:38:56
Tengo un problema con este errror
SqlParameterCollection no contiene SqlParameter con ParameterName '@valor'.
siendo que el procedimiento tengo asi
CREATE PROCEDURE [dbo].[DAU_ETARIOS_ENFERMERA]
@FechaI datetime,
@FechaT datetime,
@etarioI int,
@etarioT int
AS
BEGIN
declare
@valor int
select @valor = sum (case when PAsC_Paciente. PAsC_PAsC_Sexo ='F' then 1 else 0 end) from dbo.RPA_Formulario
Inner Join dbo.PAsC_Paciente On dbo.PAsC_Paciente.PAsC_PAsC_Numero =
dbo.RPA_Formulario.PAC_PAsC_Numero
where PAsC_Paciente.PAsC_PAsC_Numero = RPA_Formulario.PAsC_PAsC_Numero and RPA_Formulario.RPA_FOR_FechaDigit >= @FechaI and RPA_Formulario.RPA_FOR_FechaDigit <= @FechaT and DATEDIFF(yyyy, PAsC_PAsC_FechaNacim, getdate()) > = @etarioI and DATEDIFF(yyyy, PAsC_PAsC_FechaNacim, getdate()) < = @etarioT and ( RPA_FDA_TurnoProfe = '065420477-0' )
END
Dim sCnn As String
Dim totales As Integer
sCnn = "data source = casa; initial catalog = BD_SALON; user id = ; password = "
Dim slqcomand As New SqlCommand
Dim FechaI, FechaT As Date
Dim fechaII, FechaTT As String
Dim EtarioI, EtarioT As Integer
Dim hola As String
slqcomand.Connection = New SqlClient.SqlConnection(sCnn)
slqcomand.CommandType = CommandType.StoredProcedure
slqcomand.CommandText = "DAU_ETARIOS"
FechaI = Me.DateTimePicker1.Value
FechaT = Me.DateTimePicker2.Value
EtarioI = CInt(Me.TextBox1.Text)
EtarioT = CInt(Me.TextBox2.Text)
fechaII = FechaI.ToString("dd/MM/yyyy")
FechaTT = FechaT.ToString("dd/MM/yyyy")
slqcomand.Parameters.Add("@FechaI", SqlDbType.DateTime)
slqcomand.Parameters("@FechaI").Value = fechaII
slqcomand.Parameters.Add("@FechaT", SqlDbType.DateTime)
slqcomand.Parameters("@FechaT").Value = FechaTT
slqcomand.Parameters.Add("@etarioI", SqlDbType.Int)
slqcomand.Parameters("@etarioI").Value = EtarioI
slqcomand.Parameters.Add("@etarioT", SqlDbType.Int)
slqcomand.Parameters("@etarioT").Value = EtarioT
slqcomand.Connection = New SqlClient.SqlConnection(sCnn)
slqcomand.Connection.Open()
slqcomand.ExecuteScalar()
totales = slqcomand.Parameters("valor").Value
hola = totales
SqlParameterCollection no contiene SqlParameter con ParameterName '@valor'.
siendo que el procedimiento tengo asi
CREATE PROCEDURE [dbo].[DAU_ETARIOS_ENFERMERA]
@FechaI datetime,
@FechaT datetime,
@etarioI int,
@etarioT int
AS
BEGIN
declare
@valor int
select @valor = sum (case when PAsC_Paciente. PAsC_PAsC_Sexo ='F' then 1 else 0 end) from dbo.RPA_Formulario
Inner Join dbo.PAsC_Paciente On dbo.PAsC_Paciente.PAsC_PAsC_Numero =
dbo.RPA_Formulario.PAC_PAsC_Numero
where PAsC_Paciente.PAsC_PAsC_Numero = RPA_Formulario.PAsC_PAsC_Numero and RPA_Formulario.RPA_FOR_FechaDigit >= @FechaI and RPA_Formulario.RPA_FOR_FechaDigit <= @FechaT and DATEDIFF(yyyy, PAsC_PAsC_FechaNacim, getdate()) > = @etarioI and DATEDIFF(yyyy, PAsC_PAsC_FechaNacim, getdate()) < = @etarioT and ( RPA_FDA_TurnoProfe = '065420477-0' )
END
Dim sCnn As String
Dim totales As Integer
sCnn = "data source = casa; initial catalog = BD_SALON; user id = ; password = "
Dim slqcomand As New SqlCommand
Dim FechaI, FechaT As Date
Dim fechaII, FechaTT As String
Dim EtarioI, EtarioT As Integer
Dim hola As String
slqcomand.Connection = New SqlClient.SqlConnection(sCnn)
slqcomand.CommandType = CommandType.StoredProcedure
slqcomand.CommandText = "DAU_ETARIOS"
FechaI = Me.DateTimePicker1.Value
FechaT = Me.DateTimePicker2.Value
EtarioI = CInt(Me.TextBox1.Text)
EtarioT = CInt(Me.TextBox2.Text)
fechaII = FechaI.ToString("dd/MM/yyyy")
FechaTT = FechaT.ToString("dd/MM/yyyy")
slqcomand.Parameters.Add("@FechaI", SqlDbType.DateTime)
slqcomand.Parameters("@FechaI").Value = fechaII
slqcomand.Parameters.Add("@FechaT", SqlDbType.DateTime)
slqcomand.Parameters("@FechaT").Value = FechaTT
slqcomand.Parameters.Add("@etarioI", SqlDbType.Int)
slqcomand.Parameters("@etarioI").Value = EtarioI
slqcomand.Parameters.Add("@etarioT", SqlDbType.Int)
slqcomand.Parameters("@etarioT").Value = EtarioT
slqcomand.Connection = New SqlClient.SqlConnection(sCnn)
slqcomand.Connection.Open()
slqcomand.ExecuteScalar()
totales = slqcomand.Parameters("valor").Value
hola = totales
Valora esta pregunta


0