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

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
 
G

George

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.
 
J

Jeff Dillon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top