J
JJ297
Here's my stored procedure:
Create procedure Test
@Button varchar(30),
@mod char (10),
@FromDate datetime,
@ToDate datetime
AS
if @button='Button10'
begin
select * from spslist
where mod=@mod and pmtdate between @fromdate and @ToDate and PMTAMT <=
53000.01
order by pmtamt
end
if @button='Button20'
begin
select * from spslist
where mod=@mod and pmtdate between @fromdate and @ToDate and pmtamt
between 49999.99 and 53000.01
order by pmtamt
end
Here's the code behind page. How do I cast @button? Tried this below
but it's not working.
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SPSConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
Dim cmdSampling As New Data.SqlClient.SqlCommand
With cmdSampling
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "Test"
.Connection = conn
.Parameters.AddWithValue("@mod",
DropDownList1.SelectedValue)
.Parameters.AddWithValue("@Button", CType(@button,
varchar(30))
.Parameters.AddWithValue("@FromDate", FromDte.Text)
.Parameters.AddWithValue("@ToDate", ToDTE.Text)
End With
Create procedure Test
@Button varchar(30),
@mod char (10),
@FromDate datetime,
@ToDate datetime
AS
if @button='Button10'
begin
select * from spslist
where mod=@mod and pmtdate between @fromdate and @ToDate and PMTAMT <=
53000.01
order by pmtamt
end
if @button='Button20'
begin
select * from spslist
where mod=@mod and pmtdate between @fromdate and @ToDate and pmtamt
between 49999.99 and 53000.01
order by pmtamt
end
Here's the code behind page. How do I cast @button? Tried this below
but it's not working.
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("SPSConnectionString").ConnectionString)
Dim cmd As New Data.SqlClient.SqlCommand
Dim cmdSampling As New Data.SqlClient.SqlCommand
With cmdSampling
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "Test"
.Connection = conn
.Parameters.AddWithValue("@mod",
DropDownList1.SelectedValue)
.Parameters.AddWithValue("@Button", CType(@button,
varchar(30))
.Parameters.AddWithValue("@FromDate", FromDte.Text)
.Parameters.AddWithValue("@ToDate", ToDTE.Text)
End With