Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Collection object and not all of This
Message
From
05/10/2014 05:20:04
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
05/10/2014 03:55:05
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01608770
Message ID:
01608787
Views:
40
>What happens is that SQLExec can't find This.Parameters("id") in the prepared statement, and therefore prompts for its value. As you can see, the item is accessible in the someMethod context, as it should. In a first reading I couldn't find a reference for this in Tamar's paper Tore pointed to me, but may have missed it, of course.

Works this way:
	FUNCTION BuildQuery
		SQLPREPARE(THIS.REMOTE, "SELECT * FROM " + THIS.TableName + ;
			" WHERE " + THIS.RowId + ' = ?lnId')

	ENDFUNC

	FUNCTION someMethod

		MESSAGEBOX(THIS.PARAMETERS("id"))
		lnId=THIS.PARAMETERS("id")
		SQLEXEC(THIS.REMOTE)
IOW, there are limits to how far the SQL statement parser can go when analyzing and replacing anything that's prefixed with a question mark. I think it's the use of "this" in there - that reference works inside a method or event, but the SQL statement is way out of that context. You can rely only on generally available things - functions, public and private variables, perhaps even methods of global objects.

The parser is not too smart - it doesn't even know how to skip the comments, so if you ever have a question in your SQL, the question will break the statement:
sqlexec(h, "-- what happens now?"+chr(13)+"select @@version", "blabla")
will give you the nasty "SQL parameter is missing" error.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform