Reputation: 163
I have an ms sql database with a table
(Speeches)
. The columns are
(Speechid(auto increment), SpeechName(varchar), Speech_Date(date), SpeechTime(varchar)).
As you see I know the date of the Speech and the start time of every Speech.
I don’t know the End time. I want to create a query that will be refreshed from an asp.net/c# page every 2 minutes and will presents what Speech is on stage right now (live time). Is it possible?
Upvotes: 0
Views: 105
Reputation: 9074
To automatically refresh the page use this>>
<meta http-equiv="refresh" content="15">
Or
In On_Load event write,
Response.AppendHeader("Refresh", "15")
in On_Load event only take the current time from system by this>>
try
{
string curr_time= DateTime.Now.ToShortTimeString();
da=new SqlDataAdapter("select SpeechName from Speeches where SpeechTime<'"+curr_time+"'",conn);
DataSet ds=new DataSet();
da.fill(ds);
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
string speechName=ds.Tables[0].Rows[i][0].toString();//This will give you last speech within that time.
}
catch(Exception ex)
{
}
Compare it with time values in database, by this you will be able to find current speech.
Upvotes: 1