Change image position according to system time.

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2008
Posts: 37
Reputation: kischi is an unknown quantity at this point 
Solved Threads: 0
kischi kischi is offline Offline
Light Poster

Change image position according to system time.

 
0
  #1
Feb 3rd, 2009
Hi I have made a website where it is possible to see the days program on one page, it updates itself so it is only for that day.

But now I wan't to be able to insert a picture that changes position according to what time it is.

For example if the time is 1pm. then the small picture should move down to 1pm.
and if the time is 3pm the picture moves down to 3pm.

Maybe you can see what I meen on:
http://radio.web.surftown.dk/default.aspx

the time is written as datetime in my ms sql database.

my code on my aspx page looks like this:
  1. <%# Eval("tid", "{0:t}")%>

and my code on the codebehind page looks like this:
  1. SqlConnection objconn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ToString());
  2. SqlCommand objcmd = new SqlCommand();
  3.  
  4.  
  5. objcmd.Connection = objconn;
  6. objcmd.CommandType = CommandType.Text;
  7.  
  8. IF (DateTime.Now.Hour > 3)
  9. {
  10.  
  11. objcmd.CommandText = "SELECT * FROM PROGRAM WHERE CONVERT(VARCHAR, date, 105) = CONVERT(VARCHAR, GETDATE(), 105)";
  12.  
  13.  
  14. SqlDataReader reader = NULL;
  15.  
  16. objconn.Open();
  17. reader = objcmd.ExecuteReader();
  18. program.DataSource = reader;
  19. program.DataBind();
  20.  
  21. objconn.Close();
  22. }
  23.  
  24. else
  25. {
  26. objcmd.CommandText = "SELECT * FROM PROGRAM WHERE DATE = DATEADD(day, DATEDIFF(day, 1, GETDATE()), 0)";
  27.  
  28. SqlDataReader reader = NULL;
  29.  
  30. objconn.Open();
  31. reader = objcmd.ExecuteReader();
  32. program.DataSource = reader;
  33. program.DataBind();
  34.  
  35. }
  36.  
  37. }

I hope you understand what I meen and that you can help me?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kischi is an unknown quantity at this point 
Solved Threads: 0
kischi kischi is offline Offline
Light Poster

Re: Change image position according to system time.

 
0
  #2
Feb 4th, 2009
I think that this might be a way to do it?

my column in my ms sql Db that the system time has to be the same as is called tid.
So I have a suspicion that it could be done something like this:
  1. objcmd.CommandText = "SELECT tid FROM PROGRAM CONVERT(VARCHAR, GETDATE(), {0:t})";
  2.  
  3. AND then later make an IF sentence.
  4.  
  5. IF(tid == getdate() "{0:t}")
  6. {
  7. INSERT picture WITH img src="x";
  8. }

But I know that it should be written in a different way, and I am not even sure i'm on the right track.

I hope someone can please help me?
Last edited by kischi; Feb 4th, 2009 at 1:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Change image position according to system time.

 
0
  #3
Feb 6th, 2009
My friend it's not related to MS SQL Server it's about how can you play with the datetime value returned from SQL Server, as SQL Server returns the value, the problem is over here, and you can post this question to ASP.NET forum, you'd get fast response there.
Best of luck!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 37
Reputation: kischi is an unknown quantity at this point 
Solved Threads: 0
kischi kischi is offline Offline
Light Poster

Re: Change image position according to system time.

 
0
  #4
Feb 6th, 2009
Ok sorry, now I posted it in asp.net forum, I hope this helps.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: Change image position according to system time.

 
0
  #5
Feb 6th, 2009
Mark it as solved please!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC