Search code examples
entity-frameworkmodel-view-controllerentity-framework-5edmx

EF5 "the selected stored procedure or function returns no columns"


I am using EF 5 and this is my SP

USE [MYDatabase] GO
SET ANSI_NULLS ON GO
SET QUOTED_IDENTIFIER ON GO
ALTER PROCEDURE [dbo].[SP_FirstAttend] @serviceStart date, @serviceEnd date AS 
BEGIN
SET NOCOUNT OFF
SET FMTONLY OFF 

--IF (1=0) 
--BEGIN
    --SET FMTONLY ON 
    BEGIN
        DROP TABLE #temp1

        CREATE TABLE #temp1 (id int, sid int, npi int, fiscal int, serviceStart date, serviceEnd date, fcode varchar(10), tid int, StudName varchar(200), TherName varchar (200))
        INSERT INTO #temp1

        SELECT ID,
                mand.SID,
                mand.NPI,
                FiscalYear,
                ServiceStart,
                ServiceEnd,
                FundingCode,
                ther.TID,
                RTRIM(stud.StudentLastName) + ' ' + RTRIM(stud.StudentFirstName),
                RTRIM(ther.LastName) + ' ' + RTRIM(ther.FirstName)
        FROM MandateMaster AS mand
        JOIN TherapistMaster AS ther ON ther.NPI = mand.NPI
        JOIN StudentMaster AS stud ON stud.SID = mand.SID
        SELECT *,

            (SELECT top(1) sid
            FROM SessionDetail
            WHERE SID = tb1.sid
                AND TID = tb1.tid) AS val1
        FROM #temp1 AS tb1
        WHERE ServiceStart >= @serviceStart
            AND ServiceStart <= @serviceEnd;
    END 
--  END 
END

and its still giving me "Stored procedure returns no columns".

I read somewhere to set the integrated security=True; in the connection string on web.config but still nothing worked.

I been trying to find the solutions for this but keep getting the same message. Please let me know what to do .

Thanks.


Solution

  • You got nothing as result because this condition IF (1=0) always returns false then your select statement is never hit.

    Just remove this IF (1=0) and your stored procedure will return some data.