I have created a stored procedure
CREATE PROCEDURE GetCustomerWiseSales(@StartDate nvarchar(10), @EndDate nvarchar(10))
AS
SELECT C.cCode, min(C.cName) as Customer, sum(P.BeerValue) as BeerValue, sum(P.RestGroup)as RestGroup
from Customers C
Join
(
SELECT Sales.CustomerID, SUM(SalesLog.Quantity * SalesLog.Price) as BeerValue, 0 RestGroup
FROM Sales INNER JOIN
SalesLog ON Sales.MemoNo = SalesLog.MemoNo
WHERE (pGroup=8 and pSize>500) and Sales.Billdate>=@StartDate and Sales.Billdate<=@EndDate
group by Sales.CustomerID
union all
SELECT Sales.CustomerID, 0 BeerValue,SUM(SalesLog.Quantity * SalesLog.Price) AS RestGroup
FROM Sales INNER JOIN
SalesLog ON Sales.MemoNo = SalesLog.MemoNo
WHERE (pGroup!=8) and Sales.Billdate>=@StartDate and Sales.Billdate<=@EndDate
group by Sales.CustomerID
)P
on P.CustomerID=C.cCode
group by C.cCode
this SP is working nicely in Management Studio and outputs results before I blink my eyes. But when I added this SP in C# App through Data Access Layer and previewed Data using TableAdapter preview window, in first run it took 8-10 seconds to show data, in second run Preview windows threw Time Out exception. I also added a new TableAdapter with regular SQL to confirm this issues but regular SQL GetData function is working nicely.
I don't understand how a same procedure which is working nicely under same user-name and password in Management Studio, not working in DAL.
Any help would be appreciated.