Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compile SQL Reference Table query

Author  Topic 

rgh3320
Starting Member

1 Post

Posted - 2012-09-11 : 11:44:10
I am completely new to SQL server i know a few of the basics. I have a VS2010 asp.net c# application with two dropdown listboxes and a textbox. I need to calculate the numbers e.g 3 + 3 = Medium, using the table below to calculate the answer so i can insert the output value into a textbox. Could anyone please help ?

Regards Rob


Table
1 2 3 4 5
1 Cold Cold Cold Cold HOT
2 Cold Cold Cold Medium HOT
3 Cold Medium Medium HOT HOT
4 Medium Medium Medium HOT HOT
5 Medium Medium Medium HOT HOT

Drop down Listbox 3 Drop down Listbox 3

TextBox = Medium


Regards Rob

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-09-11 : 11:54:04
Create a stored procedure in your database something like shown below (I have made up column names and variable names), run the stored proc from the .net code in response to user actions, providing the selectedvalues from the list boxes to the stored proc and then display the output from the stored proc in the text box
CREATE PROCEDURE dbo.Temperature
@listBox1Value INT,
@listBox2Value INT
AS
SELECT
CASE @listBox2Value
WHEN 1 THEN Col2
WHEN 2 THEN Col3
WHEN 3 THEN Col4
WHEN 4 THEN Col5
END AS TextBoxText
FROM
YourTable
WHERE
@listBox1Value = Col1;
GO
Go to Top of Page
   

- Advertisement -