Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cancel SQL
Message
 
 
À
16/08/2005 16:08:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
01041432
Message ID:
01041448
Vues:
18
>Simply cancel a select * from [some_vfptable] thing. It's not the user who decides. It must be a cancelation by some source code. And the source code should not use ESC, because that key is already used for something else (in fact, for a messagebox( 'Cancel?' ).

If you already have SET ESCAPE ON and ON ESCAPE plCancel = YesNo('Cancel'), all you have to do is to put

SET TALK ON
SET NOTIFY ON

(see the example bellow).

The only problem if they answer No, we don't want to cancel the search, we were just playing with the keyboard. If they answer No, let's proceed with select, you would have to re-execute it, because there is no way to continue in SQL. That's something we discussed several months ago with Mike Yar.. (I can't spell his last name by memory).

This is a code from my Search form. The actual search logic is in the Search bizness object which uses Cursor Adapter. Let me know, if you want some code from that biz object too:
loWaitMessage = createobject("cWaitMessage", "Getting data...")
		loMessage = createobject("cMessage", "Getting data...")
		set escape on
		set notify on
		on escape plStop = YesNo("Are you sure you want to stop?")
		set talk on
		set talk window
		.ReallyLockScreen (.t.)
		if .oSearchCollection.requery() or .oBizObj.lNoRecordsSelected
			.ReallyLockScreen (.f.)
			if not m.plStop
				.nRecords = .oBizObj.nRecords
				loMessage.show("Your search produced " + transform(.nRecords) + " records. ")
				wait clear

				lcMessage = 'Records Found: ' + NumberCommas(.nRecords)

				if not m.plStop and .nRecords > 0 and reccount('c_Search') = 0 && Too many records
					if YesNo("Your search produced " + transform(.nRecords) + " records. " + CRLF + ;
							"It may take some time to display them." + CRLF + "Do you still want to proceed?")
						loWaitMessage.show ("Creating the final result... Please wait or press ESC to cancel")
						.ReallyLockScreen (.t.)
						.nRecords = .oBizObj.CreateFinalResult()
						.ReallyLockScreen (.f.)
					else
						lcMessage = "Too many records to display " + "(" + ;
							NumberCommas(.nRecords) + ")"
					endif
				endif


				if .nRecords = 0 or reccount(.grdSearch.recordsource) = 0
*------------------------------------
*--- No records found. Disable the
*--- grid and the Select button
*------------------------------------
					.cmdSelect.enabled = .f.
					.grdSearch.enabled = .f.
					if not m.plStop and .nRecords = 0
						MsgSvc('ErrorMsgDisplayValueOfVariable',.cNoRecordsMsg)
						lcMessage = 'No records to display'
					endif

					.SetFocusToFirst(thisform)
				else
*---------------------------------------
*--- Records found. Enable the grid
*--- and the Select button. Set focus
*--- to the grid
*---------------------------------------
					goto top
					.cmdSelect.enabled = .t.
					.cmdCancel.enabled = .t.
					.grdSearch.enabled = .t.
					.grdSearch.setfocus()
					lcMessage = 'Records Found: ' + NumberCommas(.nRecords)
					.grdSearch.highlightstyle = 2
					.cmdCancel.caption = "\<Clear" && It's not clear, not cancel
				endif
				.ReallyLockScreen (.f.)
			endif
		else
** Something went wrong
		endif

		if m.plStop
			.ReallyLockScreen (.f.)
			=ErrorMsg ('Search was cancelled!')
			lcMessage = 'Search was cancelled '
		endif
	endif

	.WaitMode(.f.)

	if m.plStop && Search was cancelled, clear the results
		.oBizObj.EmptySearchResult()
	endif
	.grdSearch.refresh()
	release loMessage, loWaitMessage
	.ChangeFormTitle(m.lcMessage)
	set message to .caption
	.cls()
endwith
plStop = .f.

* Now restore our settings
on escape &lcOnEscape
if m.lcSetEscape = "OFF"
	set escape off
endif
if m.lcSetNotify = "OFF"
	set notify off
endif

if m.lcSetTalk = "OFF"
	set talk off
endif
When I'm running Search, I can press ESC and the question is asked "Do you want to stop?" If I answer no, I re-execute the SQL.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform