Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 29, 2012 07:38 AM by Chen Yu - MSFT
Nov 25, 2012 02:40 PM|LINK
hi to all,
i am new to Asp.Net, i am stuck in a problem which is related to polling... i don't no how and where to implement this...
my scenario is as follows, in my database, i ve few tables
(First table) => Table Name : Poll, Columns :
[Question], [Option1], [Option2],
[Option3], [Result], [PollDuration],
(Second table) => Table Name : Items, Columns :
[ItemName], [Likes], [Description]
when user starts looking at items and if some user gets fascinated by an items, then he clicks on like button, which from backend increment the
[Likes] column of that [ItemName] by 1...
i want a mechanism where your suggested system will query from Items table and
"select top 3 max(likes) from items" and insert those three
[ItemNames] in table Poll and set other column values as
PollDuration = 7 days, DaysPassed = 0, ActivationDate = 1Dec2012... since today is 25Nov2012, now on one day when Server Date gets 1Dec2012, your suggested system will automaticaly display this poll in webpage...
on 2Dec2012, your suggested system will automatically set DaysPassed = 1 against that display poll, similarly on 8Dec2012 when
DaysPassed = 7, your suggested system will automatically finish this poll and update
Status = completed against this poll and start looking for new
"select top 3 max(likes) from items"
i tried my best to describe my scenario in detail... your urgent reply will make a difference in problem i am facing... i don't no how and where to implement this... either on database level or on webpage level...
Nov 25, 2012 03:09 PM|LINK
WebMatrix seems like an elegant solution for your problem.
Nov 25, 2012 03:15 PM|LINK
thanks for your reply... can you please guide me a solution / sample via WebMatrix... i no nothing about WebMatrix...
Nov 25, 2012 05:00 PM|LINK
no i guess WebMatrix is diff thing...
Nov 26, 2012 07:50 AM|LINK
can anybody answer my question... ???
Nov 26, 2012 12:00 PM|LINK
Check out a few tutorials for WebMatrix! Google is your friend.
here is one I like, it has helped me a lot!
Nov 26, 2012 04:37 PM|LINK
wavemaster, i thankful that you replied... i fully understand your said sample & i already have gone through it... bt this cant be implemented in my case... i already made a very huge web application... and the thing i am asking is just a small tiny portion
in that enormous site... if i go for WebMatrix, i need to develop everything as per its templates...
correct me if i am wrong...
i guess i need to write stored procedure / trigger / sql job to automatically initiate the entire process... but i am not sure about it... still searching google for my solution...
thanks again for showing your deep concerns, i am obligued...
Nov 29, 2012 07:38 AM|LINK
select top 3 max(likes) from items
I didn't get your point of above query, max(like) will return only one record, you could use select top 3 ItemName from Item order by likes desc to get that three records. Create sql job to execute the rest steps on time.
declare @Poll table([Question] varchar(10), [Option1] varchar(10), [Option2] varchar(10),
[Option3] varchar(10), [Result] varchar(10), [PollDuration] varchar(10), [DaysPassed] varchar(10),
declare @Items table([ItemName] varchar(10), [Likes] varchar(10), [Description] varchar(10))
insert into @Items
SELECT 'NAME1','1','aaa' UNION ALL
SELECT 'NAME2','2','aaa' UNION ALL
SELECT 'NAME3','3','aaa' UNION ALL
SELECT 'NAME4','4','aaa' UNION ALL
insert into @Poll (Question,PollDuration,DaysPassed,ActivationDate)
select top 3 ItemName,'7','0',convert(varchar(12),DATEADD(day,6,getdate()),106) from @items
order by Likes desc
select * from @poll
You could follow this article to create a SQL job: