September 11, 2012 at 9:33 am
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
1Cold Cold Cold Cold HOT
2Cold Cold Cold Medium HOT
3Cold MediumMediumHOT HOT
4MediumMediumMediumHOT HOT
5MediumMediumMediumHOT HOT
Drop down Listbox3Drop down Listbox3
TextBox output =Medium
September 11, 2012 at 9:59 am
robert.hemley (9/11/2012)
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
1Cold Cold Cold Cold HOT
2Cold Cold Cold Medium HOT
3Cold MediumMediumHOT HOT
4MediumMediumMediumHOT HOT
5MediumMediumMediumHOT HOT
Drop down Listbox3Drop down Listbox3
TextBox output =Medium
My preference for this one would be to use a lookup table. I'd then use the 'rowkey' and 'colkey' to lookup the resulting text to display.
create table lookup
(
rowkey int,
colkey int,
display varchar(10)
)
insert into lookup values (1,1,'Cold')
insert into lookup values (2,1,'Cold')
insert into lookup values (3,1,'Cold')
insert into lookup values (4,1,'Medium')
insert into lookup values (5,1,'Medium')
insert into lookup values (1,2,'Cold')
insert into lookup values (2,2,'Cold')
insert into lookup values (3,2,'Medium')
insert into lookup values (4,2,'Medium')
insert into lookup values (5,2,'Medium')
insert into lookup values (1,3,'Cold')
insert into lookup values (2,3,'Cold')
insert into lookup values (3,3,'Medium')
insert into lookup values (4,3,'Medium')
insert into lookup values (5,3,'Medium')
insert into lookup values (1,4,'Cold')
insert into lookup values (2,4,'Medium')
insert into lookup values (3,4,'Hot')
insert into lookup values (4,4,'Hot')
insert into lookup values (5,4,'Hot')
insert into lookup values (1,5,'Hot')
insert into lookup values (2,5,'Hot')
insert into lookup values (3,5,'Hot')
insert into lookup values (4,5,'Hot')
insert into lookup values (5,5,'Hot')
-- then when fetching text
select display as text_to_display
where rowkey = @rowkey and colkey = @colkey
Might not be as applicable as your decision table grows in size, but just an idea!
September 11, 2012 at 10:20 am
Thank you that will be perfect as it only goes up to 5.
September 11, 2012 at 10:27 am
awesome!
September 12, 2012 at 9:35 am
Thank you again, I know this is a SQL forum but can you help on referencing to c# i am using asp.net.
Regards Rob
September 12, 2012 at 10:08 am
robert.hemley (9/12/2012)
Thank you again, I know this is a SQL forum but can you help on referencing to c# i am using asp.net.Regards Rob
What do you mean by "help on referencing to c#"??? Are you asking how you would run that query in an asp.net page?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 13, 2012 at 2:21 am
Yes running the query in c#.
Regards rob.
September 13, 2012 at 7:52 am
robert.hemley (9/13/2012)
Yes running the query in c#.Regards rob.
The same as any other query. What have you tried so far?
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
September 13, 2012 at 8:03 am
All working fine now thanks for the help just used a sqldatasource adapter.
Regards Rob.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply