store procedure :
Set @total = ( select SUM(w.FinalAmount) from ChequeDetailsWO cdw
inner join WO w on cdw.WOCode = w.WOCode
inner join SupplierMaster sm on cdw.SupplierCode = sm.SupplierCode
inner join YearMaster ym on cdw.FinancialYear = ym.YearId
where AdvancePayment = 'true'
and cdw.SupplierCode = coalesce(@suppliercode,cdw.SupplierCode)
and cdw.WOCode = coalesce(@wocode,cdw.WOCode)
and cdw.FinancialYear = coalesce(@year,cdw.FinancialYear)
and w.WODate between coalesce(@datefrom,w.WODate) and coalesce(@dateto,w.WODate) )
select @total as 'tt', ym.Year 'Financial Year', sm.SupplierName,w.WONumber,Convert(nvarchar,w.WODate,106)'WODate',w.FinalAmount,cdw.ChequeNumber,Convert(nvarchar,cdw.ChequeDate,106)'ChequeDate',cdw.TDS from ChequeDetailsWO cdw
inner join WO w on cdw.WOCode = w.WOCode
inner join SupplierMaster sm on cdw.SupplierCode = sm.SupplierCode
inner join YearMaster ym on cdw.FinancialYear = ym.YearId
where AdvancePayment = 'true'
and cdw.SupplierCode = coalesce(@suppliercode,cdw.SupplierCode)
and cdw.WOCode = coalesce(@wocode,cdw.WOCode)
and cdw.FinancialYear = coalesce(@year,cdw.FinancialYear)
and w.WODate between coalesce(@datefrom,w.WODate) and coalesce(@dateto,w.WODate)
order by sm.SupplierName
i want to store @total on my page in variable "t"
t = ds.Tables[0].Rows[0]["@total"].ToString();
Label3.Text = t.ToString();
Ravi ShekharPosted Jul 16, 2013, 6:14 AM
You can use @total only in your query . you cannot use this one in c# code.\
You already made alias @total as tt. Means you should call tt. @total gives error.
Use t = ds.Tables[0].Rows[0]["tt"].ToString();
Mark it as answer if it helped.
Regards ,
ravi
Pradip PandeyPosted Jul 16, 2013, 5:21 AM
A minor mistake in your code, use this
t = ds.Tables[0].Rows[0]["tt"].ToString();
Hope it will help.
Riyaz AkhtarPosted Jul 16, 2013, 5:20 AM
t = ds.Tables[0].Rows[0]["tt"].ToString();
instead
t = ds.Tables[0].Rows[0]["@total"].ToString();