Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server data processing with VFP 8

bharons

Technical User
Jan 23, 2019
50
ID
good morning experts...
Please correct my code below, because only one line of data appears:
Code:
m.tanggal = thisform.txtTanggal.value
lnResult = SQLExec(Thisform.nHandle, "select top (20) * from dbo.detail where tanggal = ?m.tanggal", "detailku")
lnResult = SQLExec(Thisform.nHandle, "select top (20) * from dbo.debitur where norekening = ?detailku.norekening", "debiturku")
lnResult = SQLExec(Thisform.nHandle, "select top (20) * from dbo.nasabah where cif = ?debiturku.cif", "nasabahku")
lnResult = SQLExec(Thisform.nHandle, "select top (20) * from dbo.jaminan where norekening = ?detailku.norekening", "jaminanku")

select    debiturku.norekening,detailku.tanggal,nasabahku.nama,jaminanku.keterangan ;
from     detailku ;
join     debiturku on detailku.norekening = debiturku.norekening ;
join     nasabahku on debiturku.cif = nasabahku.cif ;
join     jaminanku on detailku.norekening = jaminanku.norekening ;
where     detailku.sandi = 3 group by 1,2,3,4 order by 1 ;
into cursor templunas readwrite

and if I browse detailku it shows a lot of data as shown in the image below
detailku.jpgdetailku1.jpg
detailku.jpg
 
Simple reason...

After the first query you have a bunch of records in the VFP cursor detailku.
Your second query has the where clause "where norekening = ?detailku.norekening". That will only put in the value of detailku.norekening in the first row of detailku.

SQL Server has no access to the VFP cursors. Even if it would, you don't join detailku in your second query, so you only get the data for one detailku.norekening value.

Why are you getting all the cursors, if you finally want the result of your VFP query, do that on the level of the SQL Server with one query in SQL Server and you'd have your final result in one go.
 

Part and Inventory Search

Sponsor

Back
Top