||Re: Switch index off - SOLVED
Mervyn Bick <email@example.com>
||Wed, 11 Oct 2017 14:15:42 +0200
On 2017-10-11 11:12 AM, Hanspeter wrote:
> Hi Mervyn, hi Akshat,
> the source code of Mervyn gave me the hint to the problem finally. If you look to my source code:
> -When the procedure starts a query is already active
> -Before I start a new query, I try to swith the index off and the problem
> -So I added following line to my code before I try to switch the inderx off:
> And after this:
> This solved the problem.
> So again thank you so much and best regards from
I'm glad you've sorted the problem out.
The problem was not actually caused by nulling the index as this can be
done on an active query. The little example I posted sets the index on
and off on an active query. One can not, however, change the sql
property of an active query. Setting the active property false allows
you to change the sql property and all is well. :-)
Instead of changing the sql property to select a new rowset you should
consider using a parameter driven query with an order by clause.
Normally an order by clause creates a read-only rowset but there is one
exception to this. The rowset is editable if the order by is on a single
field and a simple (one field only) index using the field exists. The
index does not need to be operative, it just needs to exist. In fact,
you should not set an index if you are using an order by clause. The BDE
will find it and use it to make the rowset editable.
With a parameter driven query all you need is to set the parameter and
requery() the query.
form.query1 = new query(this)
form.query1.sql = 'select * from ebene where upper(name) like :mt or
upper(direc) LIKE :mt order by upper(name)'
form.query1.params['mt'].value = '%' //this will return all records to
form.query1.active = true
dBASE is not normally case-sensitive but the parameter name in the SQL
statement and in the line assigning the value must be the same.
To make a new selection
form.query1.params['mt'] = '%'+mt+'%'