PDA

View Full Version : I can't open my database in web server



gontran
2019-05-22, 12:28
Hello I star making a web program in javascrip, but if I use

tx4.value = Lianja.evaluate("busca1('"+cJSON+"')");

the busca1.prg have this

parameter p1
oJSON = json_decode(p1)
busca1 = alltrim(oJSON.correo1)
open database dsigner
if .not. used(usuarios)
use usuarios in 0
endif
select usuarios
locate for correo = busca1
if eof()
pato = "No autorizado"
else
pato "Si puede pasar"
endif
return etos(pato)

I see I cant open my database . How can I do this ?

Thanks for the help

HankFay
2019-05-22, 12:50
Hi,

you need to


if database() <> "mydatabase"
open database mydatabase && substitute your database name
endif

at the top of your code. It has no way of knowing where the busca table is otherwise.

Now, you could also


use mydatabase!busca

instead. If you need the database open for other operations, however, open the database on its own.

Hank

PS: you don't need the periods around NOT. Here's a link to VFP operators: https://riptutorial.com/visual-foxpro/topic/7625/operators

gontran
2019-05-24, 12:26
Hello Hank.

Thanks for the solution this works perferct :)

Regards

Gontran Noble V.

HankFay
2019-05-24, 13:00
Hi Gontran,

That's great.

Now check out save/restore datasession: https://www.lianja.com/doc/index.php/SAVE_DATASESSION

Where there are repeated calls to a backend service based up multiple tables, this can eliminate a bit of overhead after the first call.

Hank