I'm calling a stored procedure from ASP.NET to grab some data for storage in an array. The problem is that in order to return the values I need, I first must call another stored procedure and dump the results into a temp table. This generates the correct records on the SQL side, but when I call it in ASP it returns the index of the last record as an int. So even though SQL generates the correct results, ASP cannot access them when calling upon the stored procedure.
Here's how I have my SQL set up:
IF OBJECT_ID('#temp') IS NOT NULL
BEGIN
DROP TABLE #temp
END
CREATE TABLE #temp
(
EventID nvarchar(50),
RunDate date,
SectionCode nvarchar(50),
SectionMapCode nvarchar(50),
DispSort int,
Capacity nvarchar(50),
Attendance int,
PctCap int,
HeatColor nvarchar(50)
)
DECLARE @runDate date = GETDATE()
--Insert results from killsheet sproc into temp table
INSERT #temp Exec GameDayReporting.dbo.uspGetEventKillSheetDetailedReport @EventID, @runDate;
select Capacity from #temp;
The SQL output:
The ASP call:
string option = TempData["option"].ToString();
var secCapacity = db.uspGetSecCapacityNew(option);
ViewData["Capacity"] = secCapacity;
System.Diagnostics.Debug.WriteLine("capacity " + secCapacity);
And the ASP output:
capacity 261
Notice how secCapacity
is equal to 261, which is the last row number in the SQL result.
So how do I access the actual query results rather than the size of the data?