Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loosing cursor position
Message
From
07/05/2018 18:49:30
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Loosing cursor position
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01659809
Message ID:
01659809
Views:
62
Hello comunity,

I have build the code bellow to connect to Mysql and create a Cursor with my exam (exame) between dates.
On my grid form is the position of my cursor is on first line and Gear=.T. for the first 4 lines, my Scan work good and i can return the value to my crTemp cursor to update my table.
But, when on my Grid form i place the cursor on 3 line, the first messagebox return the first line (exam) and after that the message form my CTemp return the last Exam ???

I think LOCATE make my SCAN loosing and not loop from 1 to 4 record
*!* Connect to MYSQL

lcServer="192.168.0.10"
lcDatabase="MyDatabse"
lcUser = "User"
lcPassword = "Mypassword"
lcStringConn="Driver={MySQL ODBC 5.2w Driver};Port=3306"+;
	";Server="+lcServer+;
	";Database="+lcDatabase+;
	";Uid="+lcUser+;
	";Pwd="+lcPassword


*-- Don't prompt for login
*SQLSETPROP(0,"DispLogin",3)
lnHandle=Sqlstringconnect(lcStringConn)

If lnHandle  > 0
	*-- open connection, get the data, then close the connection

	* -- vamos guardar as datas do painel

	ldDatIni = Date()
	ldDatFim = Date()

	ldDatIni = PDU_FCTEXM.pageframe1.udcpage2.obj9.Value
	ldDatFim = PDU_FCTEXM.pageframe1.udcpage2.obj6.Value



	**** MYSQL TABLE TO CURSOR(MyCur) ****
	TEXT TO lcSQL TEXTMERGE NOSHOW PRETEXT 7
			select  Ifnull(codiPeticioExterna,'') as 'CodPetExterno',ifnull(observacions,'') as 'observ', nomPeticio
			from Peticio LEFT join PeticioExterna  on PeticioExterna.codiPeticio = Peticio.codiPeticio
			where
				dataRecepcio between '<<Dtosql(ldDatIni)>>' and '<<Dtosql(ldDatFim)>>'
			Order by nomPeticio ASC
	ENDTEXT



	SQLExec(lnHandle, lcSQL ,"MyCur")
	SQLDisconnect(lnHandle)

	Select * From MyCur Into Cursor crTemp Readwrite

	*LOCATE
	*Select crTemp
	*Browse Normal Nowait

	FECHA([MyCur])
Else
	=Aerror(laError)
	Messagebox("Error at Connecting"+Chr(13)+;
		"Description:"+laError[2])
Endif

Select myBoListE -- is my GridName
Go Top
Scan FOR myBoListE.gerar = .T.

                       MSG(Upper(Alltrim(myBoListE.exam)))

			Select crTemp
			LOCATE For UPPER(ALLTRIM(crTemp.nomPeticio))  == Upper(Alltrim(myBoListE.exam))
				MSG( "crTEMP : " + UPPER(ALLTRIM(crTemp.nomPeticio)) )

				Text to msel textmerge noshow
					update mytable set exam = ?MyCur.CodPetExterno
                                       from mytable
                                       Where mytable.exame = ?MyCur.nomPeticio
				Endtext
				
				If u_sqlexec(msel)
				Else
					return
				Endif
				
			Select myBoListE
Endscan

Select myBoListE
go TOP
I dont understand why, could someone help me please.
Best regards,
LS
Next
Reply
Map
View

Click here to load this message in the networking platform