One of my subscribers is using MySQL as his backend so I requested him to provide a tutorial, as I do not use that backend myself, on how to use xBox on that one. This guide can be useful to others too who has a different backend aside from that of VFP. So here it is, it is quite simple actually:
Author:
Glenn Palic
Date: April 1, 2017
How to use xBox on MySQL Backend
1. Make a connection with your mysql backend using ODBC in load event of your form
Example:
Public pnConnectionHandle,oConn
oConn= "Driver={MySQL
ODBC 5.1
Driver};Server=localhost;Database=Yourdb;Port=3306;uid=username;pwd=password;Option=3;"
SQLSetprop(0,"DispLogin",3)
pnConnectionHandle = Sqlstringconnect(oConn)
If pnConnectionHandle > 0
* successs
Else
Messagebox("Can't
connect to the Server please inform network administrator.",0+32,"Error")
Quit
Endif
2. As xBox uses InteractiveChange event, then do it like this now:
Local lcSQL, lcName
lcName =[%]+Alltrim(This.Value)+[%]
TEXT TO lcSQL NOSHOW
Select LastName, FirstName, CustomerID From customer WHERE LastName like ?lcName
ENDTEXT
SQLExec(pnconnectionhandle,m.lcstr,"junk")
If !Eof()
TEXT TO lcSQL NOSHOW
Select * From junk ORDER By 1 into Cursor junkemp NOFILTER
ENDTEXT
This._searchgrid(m.lcSQL,'junkemp.LastName','junkemp.CustomerID')
Endif
And that is it!
The only difference between using VFP table is it does not need that first transfer to junk above. The second transfer to junkemp is necessary for the _SearchGrid method to kick in. I guess there won't be too much difference too on another backend such as MSSQL. Cheers!