Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Delaying tactics
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Delaying tactics

 Post Reply Post Reply
Author
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Topic: Delaying tactics
    Posted: 25 November 2003 at 10:21am
I have an action file that, when requested in delete mode, deletes the selected record from a table, using:

strSQL = DELETE tblTable.* FROM tblTable WHERE ...(etc);

adoCon.execute(strSQL)


No problems there; however I then want to check tblTable to see if it is now empty, or whether it still contains records.

However, if I then use a select statement;

strSQL = SELECT tblTable.* FROM tblTable;

rsCheckTable.Open strSQL, strCon

If rsCheckTable.EOF Then
'(Do whatever)
End If


the Select statement never reports EOF; even if the deleted record was the only one in the table, it finds (and reports, if I ask it to) that record.

So, what I need is some way of finding if the table is empty after the chosen record has been deleted. Either a way of delaying the script while the (Access) database updates, so the later select statement can return EOF if applicable, or some other way of doing this.

Any suggestions?

Thanks in advance.
www.pedalcars.info

The most fun on four wheels

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 25 November 2003 at 2:02pm

first off, this is wrong syntax:
strSQL = "DELETE tblTable.* FROM tblTable WHERE ...(etc);

it's this:
strSQL = "DELETE FROM tblTable WHERE ...(etc);

As for "if the table is empty":

strSQL = "SELECT COUNT(*) FROM tblTable"
rsCheckTable.Open strSQL, strCon  '<<== also wrong, this should be a connection object, not a string

If rsCheckTable(0) = 0 Then
      'Table is empty
Else
      'Table is not empty
End If



Edited by MorningZ
Contribute to the working anarchy we fondly call the Internet
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 27 November 2003 at 9:15am
Thanks for the corrections.

However, the check is still "finding" the deleted item - I've just been testing it, starting with one record in the table, and running the page. Checking the DB shows the record has indeed been deleted (so there's nothing in the table, at all), but the page still returns the "table not empty" clause:

If rsCheckTable(0) = 0 Then
response.write"empty!"
Else
response.write"not empty!"
End If


I get "not empty!" written each time. If I change the strSQL to a SELECT statement to bring back the record details, it will happily tell me any of them (ID, etc), even though the record was previously deleted in the DELETE statement.

Hence, I still have the original problem!

Ta
www.pedalcars.info

The most fun on four wheels

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 27 November 2003 at 9:38pm
Try
If rsCheckTable.EOF Then
response.write"empty!"
Else
response.write"not empty!"
End If
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 28 November 2003 at 2:47am
Thanks Ljamal, but that's pretty much where I came in.

I still get "not empty" reported, it's "remembering" the deleted record (yes it was the only record in the table; yes it has been deleted).

So far I've only tested this locally (Win XP / IIS / Access XP), but I can't see it being different on a live server.

Maybe I'll just have to work around the problem a different way!
www.pedalcars.info

The most fun on four wheels

Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 28 November 2003 at 8:21am
The only thing that would cause the record to still be there is if the delete condition is not being met. Are you positive the where clause of the delete statement is being met?

Try doing a select with the same where clause to see what is returned.
Back to Top
pedalcars View Drop Down
Senior Member
Senior Member


Joined: 12 August 2002
Location: United Kingdom
Status: Offline
Points: 268
Post Options Post Options   Thanks (0) Thanks(0)   Quote pedalcars Quote  Post ReplyReply Direct Link To This Post Posted: 28 November 2003 at 8:37am
The record is very definitely being deleted, yes. I can have the access table open, see the record is there, run the file, switch back to access, the record fields are now shown as "#deleted". Refresh the table and the record has gone. I've done this with multiple records existing (and it's deleting the correct one) and even with just a single record in the table, which is being deleted to leave nothing at all.

However, I do have a workaround in place now. Basically, when you view the results (from a different page), the app checks to see if said table is empty - it's not quite as efficient or as neat as I'd like, but it works.
www.pedalcars.info

The most fun on four wheels

Back to Top
theSCIENTIST View Drop Down
Senior Member
Senior Member


Joined: 31 July 2003
Location: United Kingdom
Status: Offline
Points: 440
Post Options Post Options   Thanks (0) Thanks(0)   Quote theSCIENTIST Quote  Post ReplyReply Direct Link To This Post Posted: 29 November 2003 at 1:35am

Why are you checking against the EOF? Some DB setups always have a row active.

I think you need to do it in one of two ways:

  1. Delete the record as usual, always use ID's (WHERE fldID = delID) then close the connection to the DB, open it again and make the check now.
  2. Following way no.1, after deleting store the delID on an integer (intDelID) and then check the DB if that intDelID exists.

Shouldn't be a problem.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.