Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Compile SQL Reference Table query into VS 2010 Expand / Collapse
Author
Message
Posted Tuesday, September 11, 2012 9:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 11, 2012 4:25 AM
Points: 5, Visits: 21
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 output = Medium

Post #1357523
Posted Tuesday, September 11, 2012 9:59 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, January 16, 2013 4:23 PM
Points: 415, Visits: 2,333
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
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 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!
Post #1357553
Posted Tuesday, September 11, 2012 10:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 11, 2012 4:25 AM
Points: 5, Visits: 21
Thank you that will be perfect as it only goes up to 5.
Post #1357565
Posted Tuesday, September 11, 2012 10:27 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, January 16, 2013 4:23 PM
Points: 415, Visits: 2,333
awesome!
Post #1357572
Posted Wednesday, September 12, 2012 9:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 11, 2012 4:25 AM
Points: 5, Visits: 21
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
Post #1358065
Posted Wednesday, September 12, 2012 10:08 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:04 PM
Points: 13,086, Visits: 12,553
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1358094
Posted Thursday, September 13, 2012 2:21 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 11, 2012 4:25 AM
Points: 5, Visits: 21
Yes running the query in c#.

Regards rob.
Post #1358388
Posted Thursday, September 13, 2012 7:52 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:04 PM
Points: 13,086, Visits: 12,553
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1358566
Posted Thursday, September 13, 2012 8:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 11, 2012 4:25 AM
Points: 5, Visits: 21
All working fine now thanks for the help just used a sqldatasource adapter.

Regards Rob.
Post #1358582
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse