sql query in real time...ajax?

M

mattdaddym

Hi all,

I'm looking for a way to show my users the progress of their sql
queries. I've implemented Microsoft Ajax in order to show a progress
bar, but I would love to be able to show:

number of rows loaded vs total rows

I tried a few searches for this, but haven't come up with the right
key words I guess. Right now I have zilch. So, it's easy enough to get
a count of the total rows before starting. I guess I need to query the
datasource every .5 to 1 second and display how many rows it has
retrieved already. This way the user has some idea how long the whole
thing is going to take.

Any ideas?

Thanks in advance.
 
G

George Ter-Saakov

Sound like to much effort for something small.
So far all I saw is approximations.
Like we know that on average we get 100 rows per second so if you have 1000
records will be uploaded in 10 seconds.

If user gets lucky and it ends in 9 seconds then you finish your bar early
and user happy.
If not lucky then you simply push that indicator a little back.

You should be familiar with this approach if you ever tried to Copy/Delete a
lot of files in Windows.



George.
 
M

mattdaddym

Sound like to much effort for something small.
So far all I saw is approximations.
Like we know that on average we get 100 rows per second so if you have 1000
records will be uploaded in 10 seconds.

If user gets lucky and it ends in 9 seconds then you finish your bar early
and user happy.
If not lucky then you simply push that indicator a little back.

You should be familiar with this approach if you ever tried to Copy/Delete a
lot of files in Windows.

George.

Don't talk to me about Windows OS progress bars....lol.

I don't know...this seems like basically the same concept of a
download progress bar, except instead of file sizes we are looking at
a database query. Also, it is a lot of effort...the first time. After
that, it's gravy. Thanks for your time.
 
G

Guest

Hi all,

I'm looking for a way to show my users the progress of their sql
queries. I've implemented Microsoft Ajax in order to show a progress
bar, but I would love to be able to show:

number of rows loaded vs total rows

loaded where?

If you want to see a status of the SELECT...FROM query, you cannot get
it.
I think, you can have a kind of animated gif to imitate that process.
I tried a few searches for this, but haven't come up with the right
key words I guess. Right now I have zilch. So, it's easy enough to get
a count of the total rows before starting. I guess I need to query the
datasource every .5 to 1 second and display how many rows it has
retrieved already. This way the user has some idea how long the whole
thing is going to take.

Maybe you may need to think about paging? A more efficient way to
handle this is to use SQL Server (a server-side cursor, or can be
implemented using a SQL Server stored procedure)
 
M

mattdaddym

Thanks for your response. There are some cases, like when my users are
exporting a report to excel that it would be cool to show them exactly
how much time and/or rows are left. So, if I bind a datasource to a
datatable, I cannot use client-side AJAX type code to read how many
rows have been added to the datatable?

I honestly don't know much about how this mechanism works, but I
thought the rows were added as they are received.
 
G

Guest

exporting a report to excel that it would be cool to show them exactly
how much time and/or rows are left. So, if I bind a datasource to a

In this case, I think, you offer a download the file (an export).
Make a page in between as follows. It will show a "status" of the
export.

Replace the "ExportToExcel.aspx" to a name of your export page.

----------------------------------------------------------------------------------------------------------
<%@ Page Language="vb" %>
<HTML>
<HEAD>
<script language="javascript">

var iLoopCounter = 1;
var iMaxLoop = 5;
var iIntervalId;

function BeginPageLoad() {
location.href = "ExportToExcel.aspx";
iIntervalId =
window.setInterval("iLoopCounter=UpdateProgress(iLoopCounter,
iMaxLoop)", 500);
}

function EndPageLoad() {
window.clearInterval(iIntervalId);
Progress.innerText = "Page Loaded -- Not Transferring";
}

function UpdateProgress(iCurrentLoopCounter, iMaximumLoops) {

iCurrentLoopCounter += 1;

if (iCurrentLoopCounter <= iMaximumLoops) {
Progress.innerText += ".";
return iCurrentLoopCounter;
}
else {
Progress.innerText = "";
return 1;
}
}
</script>
</HEAD>
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
Loading&nbsp;- Please Wait</span> <span id="Progress"></span>
</body>
</HTML>
 
M

markman954

In this case, I think, you offer a download the file (an export).
Make a page in between as follows. It will show a "status" of the
export.

Replace the "ExportToExcel.aspx" to a name of your export page.

----------------------------------------------------------------------------------------------------------
<%@ Page Language="vb" %>
<HTML>
<HEAD>
<script language="javascript">

var iLoopCounter = 1;
var iMaxLoop = 5;
var iIntervalId;

function BeginPageLoad() {
location.href = "ExportToExcel.aspx";
iIntervalId =
window.setInterval("iLoopCounter=UpdateProgress(iLoopCounter,
iMaxLoop)", 500);

}

function EndPageLoad() {
window.clearInterval(iIntervalId);
Progress.innerText = "Page Loaded -- Not Transferring";

}

function UpdateProgress(iCurrentLoopCounter, iMaximumLoops) {

iCurrentLoopCounter += 1;

if (iCurrentLoopCounter <= iMaximumLoops) {
Progress.innerText += ".";
return iCurrentLoopCounter;
}
else {
Progress.innerText = "";
return 1;
}}

</script>
</HEAD>
<body onload="BeginPageLoad()" onunload="EndPageLoad()">
Loading&nbsp;- Please Wait</span> <span id="Progress"></span>
</body>
</HTML>

Cool beans, I'll give it a shot. Thanks.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top