Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 passing sessionID as a parameter

Author  Topic 

Duleep_N
Starting Member

2 Posts

Posted - 2004-09-16 : 13:40:58
Hi guys;
I am developing a ASP.NET application with sql database.
I am trying to pass a sessionID as aparameter to a stored Procedure.
HERE IS THE SRORED PROCEDURE
CREATE procedure sp_RetrieveEventsByDay
@DateInput datetime,
@EmpID NVarChar
as
select * from tblEvents
where( (@DateInput between eventstartdate and eventenddate)
or (@DateInput between recurrencestart and recurrenceend)
or (@DateInput >= recurrencestart and recurrenceend Is Null) ) and Colleague_CartNumber=@EmpID
Order By EventStartTime
GO

Colleague_CartNumber is a NVarChar field in the database
Instead of the above procedure if i say....
CREATE procedure sp_RetrieveEventsByDay
@DateInput datetime,
@EmpID NVarChar
as
select * from tblEvents
where( (@DateInput between eventstartdate and eventenddate)
or (@DateInput between recurrencestart and recurrenceend)
or (@DateInput >= recurrencestart and recurrenceend Is Null) ) and Colleague_CartNumber='M922'
Order By EventStartTime
GO
it works......
i check the coding of the programme and it execute the stored procedure....
Where do i go wrong
here is the asp.net code if its any help
Dim objCmd As New SqlCommand("sp_RetrieveEventsByDay", mySqlConnection)
objCmd.CommandType = CommandType.StoredProcedure


Dim ParamdteCurrent As SqlParameter = New SqlParameter("@DateInput", SqlDbType.DateTime, 8)
ParamdteCurrent.Value = dteCurrent.ToShortDateString
objCmd.Parameters.Add(ParamdteCurrent)

Dim ParamEmpID As SqlParameter = New SqlParameter("@EmpID", SqlDbType.NVarChar, 50)
ParamEmpID.Value = Session("EmpID")
objCmd.Parameters.Add(ParamEmpID)

'Try
mySqlConnection.Open()
DR = objCmd.ExecuteReader()

CAN ANYBODY PLEASE HELP......

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-16 : 13:59:13
try:

ParamEmpID.Value = Session("EmpID").ToString()

edit:
fix the bold part too

CREATE procedure sp_RetrieveEventsByDay
@DateInput datetime,
@EmpID NVarChar(50)


Go with the flow & have fun! Else fight the flow
Go to Top of Page

Duleep_N
Starting Member

2 Posts

Posted - 2004-09-16 : 15:59:46
Thanks
It works
Go to Top of Page
   

- Advertisement -