select b.RegNo,
b.FirmName,
isnull(a.BalTaxAmount,0) + isnull(a.BalPenalty,0) + isnull(a.BalNoticeFee,0) DueAmount,
isnull(a.BalInterest,0) InterestAmt,
datediff (day, DueDate ,getdate()) duedays,
b.autoid IDtblPTForm3
from tblPTForm3Balance a, tblPTForm3 b
where a.IDtblPTForm3 = b.AutoID
and a.LocationID =
and a.YearID =
and (isnull(a.BalTaxAmount,0) + isnull(a.BalPenalty,0) + isnull(a.BalInterest,0) + isnull(a.BalNoticeFee,0)) > 0
and convert(datetime,convert(varchar(10),a.DueDate + ,101) ) <= convert(datetime,convert(varchar(10),getdate(),101))
i want to get the values of from textbox and and from dropdownlist.
to execute this query and bind data in a grid..how can i do this.
please provide me code by example..
thank you
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VasanthPosted Mar 30, 2010, 12:56 PM
Please check this ,
ALTER PROCEDURE [dbo].[spSelectBalance]
(
@intLocationID as varchar(100), -- you can use either string or int
@intYearID as varchar(100), -- if you will use integer then cast it integer to string in dynamic query
@intDays as varchar(100)
)
AS
BEGIN
DECLARE @SQLQuery as varchar(2000)
--Query generation
SET @SQLQuery = 'select b.RegNo, b.FirmName, isnull(a.BalTaxAmount,0) + isnull(a.BalPenalty,0) +
isnull(a.BalNoticeFee,0) DueAmount,isnull(a.BalInterest,0) InterestAmt,
datediff (day, DueDate ,getdate()) duedays, b.autoid IDtblPTForm3
from tblPTForm3Balance a, tblPTForm3 b where a.IDtblPTForm3 = b.AutoID and a.LocationID = '
SET @SQLQuery = @SQLQuery + @intLocationID + ' and a.YearID = ' + @intYearID
SET @SQLQuery = @SQLQuery + ' and (isnull(a.BalTaxAmount,0) + isnull(a.BalPenalty,0) +
isnull(a.BalInterest,0) + isnull(a.BalNoticeFee,0)) > 0 and convert(datetime,convert(varchar(10),a.DueDate + '
SET @SQLQuery = @SQLQuery + @intDays + ',101)) <= convert(datetime,convert(varchar(10),getdate(),101))'
--Print the Query
PRINT(@SQLQuery)
--Execute the Query
EXEC(@SQLQuery)
END
--Finally execute the SPs
EXEC spSelectBalance '3','1983','25'
If it helps you , please mark as answer.