How to update the sql query data in the background silently?

  • Thread starter Thread starter WuBin
  • Start date Start date
W

WuBin

Hi,

I have a GridVew and a sqlDtaSurce control in ASP.NET real-time page.
The sqlDtaSurce control use a complicated query to load data from a
SQL database.

This real-time page is reloaded by java script 'window.open' from
another page every 5 minutes.

Because the query takes about 2 minutes to finished query, so the real-
time page will blank for 2 minutes everytime when it is reload.

Is it possible to load the data in the background when displaying the
old data? Then update GridView to the new data in one second after the
query is finished.

Thanks,

Ben
 
here is an idea (i am using to keep session alive)

<IMG id=renewSession height=1 src="/images/spacer.gif" width=1 border=0
name=renewSession>

<script language="Javascript">
window.setInterval("renewSession();", 6000);
function renewSession()
{document.images["renewSession"].src = "/renewSes.ashx?par=" + (new
Date()).toLocaleString();}
</script>

------------renewSes.ashx----------------------------
public class GKeepSessionAliveHandler : IHttpHandler,
System.Web.SessionState.IReadOnlySessionState
{
static byte[] gif =
{0x47,0x49,0x46,0x38,0x39,0x61,0x01,0x00,0x01,0x00,0x91,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0xf9,0x04,0x09,0x00,
0x00,0x00,0x00,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x08,0x04,
0x00,0x01,0x04,0x04,0x00,0x3b,0x00};

public GKeepSessionAliveHandler()
{
}


#region IHttpHandler Members

public bool IsReusable
{
get { return true; }
}

public void ProcessRequest(HttpContext ctx)
{
ctx.Response.AddHeader("ContentType", "image/gif");
ctx.Response.Cache.SetCacheability(HttpCacheability.NoCache);
ctx.Response.BinaryWrite(gif);
//ctx.Response.End();
}

#endregion
}

you obviously will have to write your own renewSes.ashx to do what you want
to do with your database
Just make sure you output transparent pixel first then do your work... And
if you do not need Session remove support IReadOnlySessionState

Problem is that ASP.NET serializes requests to the same session. so while
one request executes for 2 minutes all other requests for the same session
will be put on hold.

George.
 
WuBin said:
Hi,

I have a GridVew and a sqlDtaSurce control in ASP.NET real-time page.
The sqlDtaSurce control use a complicated query to load data from a
SQL database.

This real-time page is reloaded by java script 'window.open' from
another page every 5 minutes.

Because the query takes about 2 minutes to finished query, so the real-
time page will blank for 2 minutes everytime when it is reload.

Is it possible to load the data in the background when displaying the
old data? Then update GridView to the new data in one second after the
query is finished.

Thanks,

Ben

Fix the query
 
Back
Top