473,396 Members | 1,990 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,396 software developers and data experts.

SQL Delete Timeout

Hi all,

I'm getting an error from something that seems too easy to cause
trouble. Here's the scenario. User fills out a form. User saves. On
submit, an asp script attempts to save the data. it deletes all of
existing child records, and then re-inserts new child records.

Heres the chunk of code thats bombing out with a 'Microsoft OLE DB
Provider for SQL Server error '80040e31' ':

'delete all children for this Parent record
strSQL = "DELETE FROM qcspec_is_tasks WHERE parentID = " & nRecID
debugPrint strSQL
cn.Execute strSQL

The print statement yeilds the following, before the Execute statement
dies:

DELETE FROM qcspec_is_tasks WHERE parentID = 20

If I run the above in query analyzer, it executes instantly.

Incidentally, at this point in time, the table is tiny. Its only 50
rows or so, at the moment.

I've looked into google, and the group archives, but I never saw any
solution to the problem.
Feb 15 '06 #1
7 3590
Here's an added confusion:

If I change

'delete all children for this Parent record
strSQL = "DELETE FROM qcspec_is_tasks WHERE parentID = " & nRecID
debugPrint strSQL
cn.Execute strSQL


to this:
'delete all children for this Parent record
strSQL = "SELECT * FROM qcspec_is_tasks WHERE parentID = " & nRecID
debugPrint strSQL
cn.Execute strSQL

Then my program continues to execute. It adds duplicate items into the
table every time the item saves, but it shows that the connection is
working.

Any ideas?

Thanks,

Brian Ackermann
Feb 15 '06 #2
Brian J. Ackermann wrote:
Any ideas?


Looks like I solved my own question.

I added an index to the 'parentID' field, and the Delete statement works
instantly.

Thanks for reading!

Brian Ackermann
Feb 15 '06 #3
Brian J. Ackermann wrote:
Here's an added confusion:

If I change

'delete all children for this Parent record
strSQL = "DELETE FROM qcspec_is_tasks WHERE parentID = " & nRecID
debugPrint strSQL
cn.Execute strSQL


to this:
'delete all children for this Parent record
strSQL = "SELECT * FROM qcspec_is_tasks WHERE parentID = " & nRecID
debugPrint strSQL
cn.Execute strSQL

Then my program continues to execute. It adds duplicate items into
the table every time the item saves,


Really? No primary key on the table? No unique index or constraint?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 15 '06 #4
Brian J. Ackermann wrote:
Hi all,

I'm getting an error from something that seems too easy to cause
trouble. Here's the scenario. User fills out a form. User saves.
On submit, an asp script attempts to save the data. it deletes all of
existing child records, and then re-inserts new child records.
Well, I see signs of trouble already...why not just update in place?

Heres the chunk of code thats bombing out with a 'Microsoft OLE DB
Provider for SQL Server error '80040e31' ':


Jeez, I don't have all these error codes memorized - please provide the text
of the message.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 15 '06 #5
Brian J. Ackermann wrote:
Brian J. Ackermann wrote:
> Any ideas?


Looks like I solved my own question.

I added an index to the 'parentID' field, and the Delete statement
works instantly.

Still ... why delete and insert? Why not update in place?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Feb 15 '06 #6
Bob Barrows [MVP] wrote:
Still ... why delete and insert? Why not update in place?


I'll give you an example. We have an application that asks users to
inventory certain types of resources they use within our company. The lists
of available resources are quite long (numbering in the hundreds), but few
individuals use many items, so it makes sense to only store their
selections, and not items that they do not select.

Like the OP, we have a parent-child relationship in which we need to keep a
list of children.

Suppose a user makes his selections, then comes back to make changes. At
form submission, we have several choices for dealing with potential
deselections, namely (1) delete them all and store only what is submitted,
(2) report to the DB the selection status for every single item, (3) retain
the PREVIOUSLY SELECTED values in hidden form fields and use the form
submission to determine which selections to delete, or (4) compare every
single PREVIOUSLY SELECTED item to the current selection list.

It seems to me that (1) and (3) are the only reasonable choices. We made the
same choice as the OP, and probably for the same reason -- it is
considerably easier to implement and maintain and there is a reasonable
expectation of performance equivalence.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Feb 16 '06 #7
Dave Anderson wrote:
Bob Barrows [MVP] wrote:
Still ... why delete and insert? Why not update in place?


I'll give you an example.

<snip>
That's a certainly valid design choice. And it does seem to fit the OP's
situation, given the "WHERE ParentID = ..." (whose significance I initially
missed), so I will consider myself corrected. Thanks
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Feb 16 '06 #8

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

Similar topics

2
by: Ryan | last post by:
I have a table in my database on SQL Server which holds a file name that refers to a file that is stored on the server. I would like to create a trigger to delete this file from the server if the...
4
by: Együd Csaba | last post by:
Hi All, I've a problem with unclosed connections. Once a client aborts a connection accidentelly (client crash or power failure eg.), it stucks in and postgres won't restart or stop. Is there any...
3
by: Ray | last post by:
I am having my first experience using BLOB as a row in a table. I am using it to insert graphics for labels we print. I have no problem inserting into and select from the table. The graphic is...
3
by: Mullin Yu | last post by:
As subject. How can an main application delete/reset a thread at the ThreadPool? There's no method provided by ThreadPool? Thanks!
1
by: darrel | last post by:
I'm trying to figure out why I can't delete a file from within my application. Part of my application is protected via forms authentication. If I try to call a delete file function from within...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
4
by: Ignoramus6539 | last post by:
There were some strange requests to my server asking for config.php file (which I do not have in the requested location). I did some investigation. Seems to be a virus written in perl,...
2
vanc
by: vanc | last post by:
I'm trying to delete a table with just around 2000 rows. What I got is timeout error. I can't use Truncate Table, which is very quick, because I have Trigger with Delete command. Is there any way to...
107
by: bonneylake | last post by:
Hey Everyone, Well for the last few days i been trying to figure out how to delete attachments and download attachments to my computer. The deleting is sort of working and i don't know where to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.