HeavenCore
Well-known member
Hi, this is doing my HEAD in lol, hope you can help. I need to produce a report (i am using the MS reportviewer system) to evaluate a jobs costs. Easy enough, i have dozens of reports working fine with normal table adapters, but to evaluate Job cost takes several quries so i wrote a stored procedure to return a row of all the information:
OK, so this works great in ms sql management studio, i get:
but when i try to create a table adapter to get this infromation, i just an error:
Invalid Object Name '##Results'
What am i doing wrong?
VB.NET:
ALTER PROCEDURE Job_Cost_Details_2
@JobID int
AS
Declare @HireCost money
Declare @wages money
Declare @JobPlantCharge money
Declare @Stock money
Declare @WaistAmount money
Declare @Expenses money
Declare @QuoteID int
Declare @QuoteAmount money
Declare @TotalCosts money
Declare @Proffit money
SET @HireCost = ISNULL((SELECT SUM(HireCost) AS TotalHireCost FROM tblHire WHERE HireJob_fk = @JobID),0);
SET @wages = ISNULL((SELECT SUM(WagesRate * WagesHours) from tblWages where WagesFKJob = @JobID),0);
SET @JobPlantCharge = ISNULL((SELECT SUM(JobPlantCharge) AS TotalPlantCost FROM tblPlantJob WHERE JobPlantJob_fk = @JobID),0);
SET @Stock = ISNULL((SELECT SUM(StockToJobPrice) AS TotalStockCost FROM tblStockToJob WHERE StockToJobJobs_fk = @JobID),0);
SET @WaistAmount = ISNULL((SELECT SUM(WaistAmount * WaistCostPerUnit) FROM tblWaist WHERE WaistJob_fk = @JobID),0);
SET @Expenses = ISNULL((SELECT SUM(ExpensesCost) AS TotalOtherCost FROM tblExpenses WHERE ExpensesJob_fk = @JobID),0);
SET @QuoteID = (SELECT fk_JobJobQuote FROM tblJobs WHERE JobDatabaseID = @JobID);
SET @QuoteAmount = ISNULL((SELECT QuotePrice FROM tblQuote WHERE QuoteID = @QuoteID),0);
SET @TotalCosts = (@HireCost + @wages + @JobPlantCharge + @Stock + @Expenses + @WaistAmount);
SET @Proffit = (@QuoteAmount - @TotalCosts);
CREATE TABLE ##Results (
HireCost money,
wages money,
JobPlantCharge money,
Stock money,
WaistAmount money,
Expenses money,
QuoteID int,
QuoteAmount money,
TotalCosts money,
Proffit money);
Insert into ##Results (
HireCost,
wages,
JobPlantCharge,
Stock,
WaistAmount,
Expenses,
QuoteID,
QuoteAmount,
TotalCosts,
Proffit
)
Values
(
@HireCost,
@wages,
@JobPlantCharge,
@Stock,
@WaistAmount,
@Expenses,
@QuoteID,
@QuoteAmount,
@TotalCosts,
@Proffit
);
Select * From ##Results;
OK, so this works great in ms sql management studio, i get:
VB.NET:
HireCost wages JobPlantCharge Stock WaistAmount Expenses QuoteID QuoteAmount TotalCosts Proffit
---------------- ---------------- ---------------- ---------------- ---------------- ---------------- ----------- ---------------- ---------------- ----------------
5 297.5 44 45.98 144 0 1 500 536.48 -36.48
(1 row(s) affected)
(1 row(s) returned)
but when i try to create a table adapter to get this infromation, i just an error:
Invalid Object Name '##Results'
What am i doing wrong?