Parameters

G

Guest

Hi,

I wish obtain one table with the month results and year accumulate to
selected month .

I have the following SQLServer table:

Item/ Month/ValueUSD
A / 01/ 10,00
A / 02/ 15,00
B /01/ 8,00
B /02/ 12,00

My SQLServer Function is:

ALTER FUNCTION dbo.fnCompare(
@month nvarchar(2))

RETURNS TABLE
AS
RETURN ( SELECT item, month, valueUSD,
CASE WHEN
month = @month
THEN valueUSD ELSE 0 END AS MonthValue
FROM dbo.vsCompare
WHERE (month <= @month)

Additionally I have created agregate sum function and correspondent stored
procedure.

And in Visual Studio (VB.NET), I have one DropDownList and one DataGrid; in
the code behind Webform I wrote:

..Parameters("@month").Value = Dropdownlist1.SelectedItem.Text

My WebForm show the following DataGrid resultate: (for @Month = "02")

Items/MonthValue/AcumValue
A / 0,00/ 25,00
B/ 0,00/ 20,00

instead,

Items/MonthValue/AcumValue
A / 15,00/ 25,00
B/ 12,00/ 20,00

I lost the MonthValue.

(I proved in the Sql Analyzer and SQLDataAdapter preview and the result is
OK. And DataGrid no show

MonthValue.)

The "CASE WHEN month = @month" parameter no passed and the
WHERE (month <= @month) parameter passed correctly.

Why?

Thank you in advance for any help.

Adis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,266
Messages
2,571,081
Members
48,772
Latest member
Backspace Studios

Latest Threads

Top