Alter PROCEDURE "sp_getsession" <BR> @USERID NVARCHAR(50),<BR> @TIMEOUTVAL int<BR>AS<BR> DECLARE @CNTVALS INTEGER<BR> DECLARE @TIMENOW as DATETIME<BR> DECLARE @SESSIONID NVARCHAR(50)<BR><BR> SET @TIMENOW = getDate()<BR> <BR> SELECT @CNTVALS=COUNT(userid) FROM sessions WHERE ((userid = @USERID) AND (DATEDIFF(MINUTE, time_stamp, @TIMENOW) &#060;= @TIMEOUTVAL)) --within 20 Minutes<BR><BR> IF (@CNTVALS = 1) --Only one value was returned, look up that GUID & return to user<BR> BEGIN<BR> SELECT sessionid FROM gongle_sessions WHERE ((userid = @USERID) AND (DATEDIFF(MINUTE, time_stamp, @TIMENOW) &#060;= @TIMEOUTVAL)) --within 20 Minutes<BR> END<BR> ELSE<BR> BEGIN<BR> SET @SESSIONID = NEWID()<BR> INSERT INTO sessions (sessionid, time_stamp, userid) VALUES (@SESSIONID, getDate(), @USERID)<BR> SELECT sessionid FROM sessions WHERE sessionid = @SESSIONID<BR> END<BR> RETURN<BR><BR><BR>-----------<BR>observe the above SP.<BR>One would think that this would return a result to the asp code calling it even if it was a result set of zero records. <BR>Not so. if the second branch of the if statement is executed (the one with the insert statment) the very presence of the INSERT statement apparently renders the SP as the type of SP that returns no defined result set ... not even a result set of zero records.<BR><BR>Hence using...<BR>Set rs = sessioncon.execute("execute sp_getsession &#039" & userid & "&#039,&#039" & timout & "&#039")<BR><BR>and then trying to make any reference to rs in your code results in an object is closed error.<BR><BR>Now if you were to remove the INSERT statement and rerun the SP you will discover that after referencing rs no error occurs even if no records were returned from the SP.<BR><BR>Is there anyway around the behaviour that occurs where the SP is present?<BR><BR>Thanks