locked
ASP page with SQL Query RRS feed

  • Question

  • User314929022 posted

    So I am very new to this but I have an issue.

    I need a wallboard of sorts that will display realtime information and update every 15 seconds or so. I have a SQL Query written that pretty much gives me what I need in a table but I need to split the results based on the status of the results and I am wondering what is the best method to use. 

    I am terrible at explaining so I'll write an example. 

    If I were working for a construction company and wanted a web page that would show what workers are on the clock once they clock in. Their name would change color/location on the page if they are on break/lunch/meetings etc. The currently query I have gives me everyone on the clock and their status. What method would you recommend for manipulating that data so I could present it? 

    Thanks in advance. Sorry this was a long post. 

    Tuesday, November 27, 2018 7:31 PM

All replies

  • User283571144 posted

    Hi ASPnewbie751,

    According to your description, I suggest you could try to use javascript setinterval function to achieve your requirement.

    Description and usge:

    The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).

    The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed.

    The ID value returned by setInterval() is used as the parameter for the clearInterval() method.

    Tip: 1000 ms = 1 second.

    Tip: To execute a function only once, after a specified number of milliseconds, use the setTimeout() method.

    I suggest you could use setinterval function to call a ajax function which will call the server's method to run the sql query to get the engineer status, then you could modify the page's element according to the ajax response data.

    More details about how to use ajax to send the data to the server,you could refer to below article:

    https://www.aspsnippets.com/Articles/Call-ASPNet-Page-Method-using-jQuery-AJAX-Example.aspx 

    Best Regards,

    Brando

    Wednesday, November 28, 2018 2:58 AM
  • User379720387 posted

    Let's assume you have two tables:

    A - aId, fname, lname, 

    B - bId, aId, timeStamp, some on the clock flag

    The relationship is 1 to n: i.e. one worker has one or more records in table B.

    The query:

    select aId, fName, lName, the on the clock flag

    from table a

    LEFT JOIN table b ON a.aId =b.aId

    WHERE timeStamp = today

    You get a result for all workers, and some have the timeStamp, and the on the clock flag

    Tuesday, December 4, 2018 5:50 PM