I'd bet that Barbara is right about the view definition being complex. I believe that VFP does in fact go out to the database to ensure that tables and columns exist. I'm curious about the comparative timing of the following opens:
1) USE ... NODATA
2) USE (without the NODATA clause) with a parameter which returns no rows.
3) USE (without the NODATA clause) with a parameter which returns rows.
By the way, I'd watch out for the assumption that a view will be faster than SPT. It used to be the opposite, and I believe I've read that now the differences are negligible. One approach we have used is to bind controls to an SPT that does not get queried until we're ready for the data. In the LOAD event of the form, we do a simple CREATE CURSOR with the same cursor and field names as the SPT cursor will have - this allows the controls to bind without complaint. For instance, the LOAD event would contain:
CREATE CURSOR MyPassThrough ;
(MyCharField C(1), MyNumField N(1))
... and then, when you really want the data, you can do:
SQLEXEC(THISFORM.nHandle, "SELECT MyCharField, MyNumField ...", "MyPassThrough")
You might try this, assuming an SPT meets your needs, as the CREATE CURSOR is about instantaneous.
zahid
>Gabriel,
>I've never seen it take more than a fraction of a second to load a view with the "NoDataOnLoad" set. Can you repeat this in a PRG and from the command window? If it's in a form are you sure it is this command?
>
>Are these very complex views loading multiple tables?
>
>Are your indexes set to optimize Rushmore (or SQL-Server if that's where your data is)?
>
>Barbara
>
>>When attempting to use a view without downloading data either by means of the nodata clause in the use command, or by setting the cursor's NoDataOnLoad property to .T. when the view is added to a form's dataenvironment, the view is first executed.
>>
>>When dealing with large tables this can take a long time (about 3 to 4 minutes in my case). Is there any way to prevent the execution of the view.
>>
>>I could create a cursor instead of using a view, but as I understand it, a view is faster than a cursor.
>>
>>Any ideas or suggestions would be appreciated.