SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Compile SQL Reference Table query into VS 2010


Compile SQL Reference Table query into VS 2010

Author
Message
robert.hemley
robert.hemley
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
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
patrickmcginnis59
patrickmcginnis59
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1511 Visits: 2333
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!
robert.hemley
robert.hemley
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 21
Thank you that will be perfect as it only goes up to 5.
patrickmcginnis59
patrickmcginnis59
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1511 Visits: 2333
awesome!
robert.hemley
robert.hemley
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
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
Sean Lange
Sean Lange
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60833 Visits: 17954
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.

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)
robert.hemley
robert.hemley
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 21
Yes running the query in c#.

Regards rob.
Sean Lange
Sean Lange
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60833 Visits: 17954
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.

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)
robert.hemley
robert.hemley
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 21
All working fine now thanks for the help just used a sqldatasource adapter.

Regards Rob.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search