473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

SQL Statement Issue

I have a SQL statement that takes our server 2 minutes to return results,
and when the program is waiting for the results it appears to be
hung/crashed. Is there a way to keep this from happening? It happens with
almost every program I write that reads data from our old AS/400. The
queries usually take 10 sec. to several minutes to return data from the
server. Can I use a timer to control this?

Here is the code:

strSQL = "SELECT F42119.SDDOC, F42119.SDDCT FROM BURNS.F42119 WHERE " & _
"F42119.SDIVD = " & strDate & " ORDER BY F42119.SDDOC"

daInvoices = New OleDb.OleDbDataAdapter(strSQL, strConnect)
'Takes 2 mintues to run and the program seems to be frozen
daInvoices.Fill(dtInvoices)
dgInvoices.DataSource = dtInvoices

Thanks,
David
Nov 20 '05 #1
5 1124
If this is a windows program, I recommend you launch a separate thread, and
have that thread execute the query and bind the data.

"David Doing" <do***@cny-golf.com> wrote in message
news:Oe**************@TK2MSFTNGP09.phx.gbl...
I have a SQL statement that takes our server 2 minutes to return results,
and when the program is waiting for the results it appears to be
hung/crashed. Is there a way to keep this from happening? It happens with almost every program I write that reads data from our old AS/400. The
queries usually take 10 sec. to several minutes to return data from the
server. Can I use a timer to control this?

Here is the code:

strSQL = "SELECT F42119.SDDOC, F42119.SDDCT FROM BURNS.F42119 WHERE " & _
"F42119.SDIVD = " & strDate & " ORDER BY F42119.SDDOC"

daInvoices = New OleDb.OleDbDataAdapter(strSQL, strConnect)
'Takes 2 mintues to run and the program seems to be frozen
daInvoices.Fill(dtInvoices)
dgInvoices.DataSource = dtInvoices

Thanks,
David

Nov 20 '05 #2
Thank you for your quick response...
but, what should I put in the new thread, and how do I return the results to
the calling thread?

Thanks,
David
"Marina" <nospam> wrote in message
news:ec**************@TK2MSFTNGP10.phx.gbl...
If this is a windows program, I recommend you launch a separate thread, and have that thread execute the query and bind the data.

"David Doing" <do***@cny-golf.com> wrote in message
news:Oe**************@TK2MSFTNGP09.phx.gbl...
I have a SQL statement that takes our server 2 minutes to return results, and when the program is waiting for the results it appears to be
hung/crashed. Is there a way to keep this from happening? It happens

with
almost every program I write that reads data from our old AS/400. The
queries usually take 10 sec. to several minutes to return data from the
server. Can I use a timer to control this?

Here is the code:

strSQL = "SELECT F42119.SDDOC, F42119.SDDCT FROM BURNS.F42119 WHERE " & _ "F42119.SDIVD = " & strDate & " ORDER BY F42119.SDDOC"

daInvoices = New OleDb.OleDbDataAdapter(strSQL, strConnect)
'Takes 2 mintues to run and the program seems to be frozen
daInvoices.Fill(dtInvoices)
dgInvoices.DataSource = dtInvoices

Thanks,
David


Nov 20 '05 #3
1) I'd investigate why it takes two minutes and address that first.
INdexes may help for instance although not necessarily a magic bullet.
It's not record size I'm guessing b/c you are probably only returning a
record or few records
2) > strSQL = "SELECT F42119.SDDOC, F42119.SDDCT FROM BURNS.F42119 WHERE "
& _
"F42119.SDIVD = " & strDate & " ORDER BY F42119.SDDOC" should be changed to "SELECT F42119.SDDOC, F42119.SDDCT From
BURNS.F42119 WHERE F42119.SDIVD = ? Order by F42119.SDDOC"

Then add a parameter to the parameters collection. That should also speed
things up slightly but that's not the source of the problem.

Finally, yes, seperate threads can also help the freezing up, but you will
still have the program waiting for a return set.
"David Doing" <do***@cny-golf.com> wrote in message
news:Oe**************@TK2MSFTNGP09.phx.gbl... I have a SQL statement that takes our server 2 minutes to return results,
and when the program is waiting for the results it appears to be
hung/crashed. Is there a way to keep this from happening? It happens with almost every program I write that reads data from our old AS/400. The
queries usually take 10 sec. to several minutes to return data from the
server. Can I use a timer to control this?

Here is the code:

daInvoices = New OleDb.OleDbDataAdapter(strSQL, strConnect)
'Takes 2 mintues to run and the program seems to be frozen
daInvoices.Fill(dtInvoices)
dgInvoices.DataSource = dtInvoices

Thanks,
David

Nov 20 '05 #4
"David Doing" <do***@cny-golf.com> schrieb
Thank you for your quick response...
but, what should I put in the new thread,
The execution of the query.
and how do I return the
results to the calling thread?

http://msdn.microsoft.com/library/en...isualBasic.asp

especially sub topic "Parameters and Return Values for Multithreaded
Procedures"

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
William,
Thank you for your response. Indexing most likely is the issue, plus the
fact that this server is 5 yrs. old and not too reponsive with 50+ users
logged in. Parameters will most likely speed things up as well, but what's
1.4 minutes vs. 1.5? The users understand it takes a few minutes to return
the records, they just don't like the fact that the interface appears frozen
the entire time. Threads will solve this problem, and I will begin
re-writing to include them.

Thanks.
David

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:ua**************@tk2msftngp13.phx.gbl...
1) I'd investigate why it takes two minutes and address that first.
INdexes may help for instance although not necessarily a magic bullet.
It's not record size I'm guessing b/c you are probably only returning a
record or few records
2) > strSQL = "SELECT F42119.SDDOC, F42119.SDDCT FROM BURNS.F42119 WHERE " & _
"F42119.SDIVD = " & strDate & " ORDER BY F42119.SDDOC"

should be changed to "SELECT F42119.SDDOC, F42119.SDDCT From
BURNS.F42119 WHERE F42119.SDIVD = ? Order by F42119.SDDOC"

Then add a parameter to the parameters collection. That should also speed
things up slightly but that's not the source of the problem.

Finally, yes, seperate threads can also help the freezing up, but you will
still have the program waiting for a return set.
"David Doing" <do***@cny-golf.com> wrote in message
news:Oe**************@TK2MSFTNGP09.phx.gbl...
I have a SQL statement that takes our server 2 minutes to return results, and when the program is waiting for the results it appears to be
hung/crashed. Is there a way to keep this from happening? It happens

with
almost every program I write that reads data from our old AS/400. The
queries usually take 10 sec. to several minutes to return data from the
server. Can I use a timer to control this?

Here is the code:


daInvoices = New OleDb.OleDbDataAdapter(strSQL, strConnect)
'Takes 2 mintues to run and the program seems to be frozen
daInvoices.Fill(dtInvoices)
dgInvoices.DataSource = dtInvoices

Thanks,
David


Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
3
by: Mark Morton | last post by:
I'm writing an if statement for a UK credit card form validation script. Users who specify that their card is Switch need to enter either the issue number or the 'valid from' date. I'm trying to...
3
by: Andy_Khosravi | last post by:
I have been trying to build a user friendly search engine for a small database I have created. I'm having some particular problems with one of my date fields. Here's the setup: I'm using...
10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
6
by: Not4u | last post by:
Hello Config : SQL 2000 on WIN 2000 (IIS 5.0) In my ASP page for some queries i have this error : Microsoft OLE DB Provider for SQL Server error '80040e31' Timeout expired
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
7
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
8
by: nano2k | last post by:
Hi Shortly, I keep invoices in a table. Occasionally, someone will fire the execution of a stored procedure (SP) that performs several UPDATEs against (potentially) all invoices OLDER than a...
18
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.