Subject Re: Findkey on mysql
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 01 Jul 2015 17:41:00 +0200
Newsgroups dbase.getting-started

On Wed, 01 Jul 2015 17:03:04 +0200, Onwu Bami <bamionwu@yahoo.com> wrote:

> Hello all,
>
> How do I recode the below .dbf findkey code to mysql code.
>
> local lookfor
>       lookfor=this.value
>       //I am referencing the table directly here because
>       //I had previously dragged the table to the form surface.
>       If form.mainaccount1.rowset.findKey( lookfor )
>          form.entmainacctno.value:=form.mainaccount1.rowset.fields['mainacctno'].value
>          form.entmainacctname.value:=form.mainaccount1.rowset.fields['mainacctname'].value
>                         form.entmainaccttype.value:=form.mainaccount1.rowset.fields['mainattype'].value
>       ELSE
>          msgbox('Main Account Not Updated')
>          RETURN true
>       ENDIF
>       return

If you are using MySQL to store your data the methods that rely on a dBASE  
index, such as findkey() or setRange(), will not work.  You should use the  
applyLocate() method instead.   This is, however, only part of the story.


Working with a RDBM such as MySQL requires a completely different approach  
to working with .dbf files.  Using ordinary queries to read an write as  
one does with .dbf tables can have a bad effect on the SQL server.  You  
should be using read-only queries to fetch data and the SQL UPDATE command  
to replace values and the INSERT command to add new records.

Even if you are using the BDE to access MySQL, have a look at the ADO  
newsgroup where the techniques for accessing SQL tables have been  
discussed recently in some depth.  There are also messages in the  
sql-servers newsgroup but these are a bit older.

Mervyn.