ADS Rdd EoF function

This forum is meant for questions and discussions about the X# language and tools
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Hi Robert

I use the function:
XSharp.RDD.Functions.AdsAtEOF(SELF:nCursor, OUT nRet)
to check the EoF state in my own server class.
This function now always returns false if the cursor has no records.
It happens with the last build: 2.12.2.1
If I go back to 2.11.0.1 it works as expected.

Markus
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ADS Rdd EoF function

Post by robert »

Markus,
That function is directly mapped to the underlying ADS API.
So if there is a problem it is most likely coming from another location.
And I cannot remember changing anything in this area (the ADS code) that could explain this.
Can you create a small example demonstrating the problem ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Hi Robert
I just sent you a link to the sample project file on onedrive.
The problem must be in the Execute() method of the class dbAdsServer.
No statement and therefore no cursor is created.
This code worked until version 2.11.0.1.

HTH Markus
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ADS Rdd EoF function

Post by robert »

Markus,
Check your mail.
I have created a ticket for this:
https://github.com/X-Sharp/XSharpPublic/issues/1054

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Thank you very much for your great support!
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Robert,
I just did your recommended workaround. It still does not work. I broke it down to this line of code (in the execute() method:


self:nAdsRet := XSharp.RDD.Functions.AdsCreateSQLStatement(self:nConnection, @nStat)

The self:nConnection holds a valid connection handle. After this call the nStat (statement handel) remains a null object.
The return value of this function is 0 (=no error).

Markus
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ADS Rdd EoF function

Post by robert »

Markus,

In the example that you have given me is nStat an IntPtr and it gets set to a valid statement handle.


Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Robert,

thats really strange. If I call in my fixed sample the AdsCreateSQLStaement() function ADS returns a 5024 (The application deleted an Advantage handle at the same time it attempted to use the handle.) error which makes no sense here. I just put this version of the sample to the same location on OneDrive which you can access with the link I sent before. Perhaps (for sure) I oversee something.

Markus
markus.lorenzi@dvbern.ch
Posts: 107
Joined: Mon May 02, 2016 9:10 am
Location: Schweiz

ADS Rdd EoF function

Post by markus.lorenzi@dvbern.ch »

Robert,
I just found the real reason why the code was failing. There must something have changed with the codeblock handling.
In the failing version the variables needed in the codeblock were declared outside the codeblock:

Code: Select all

method Execute()	
[b]	local nStat		as	IntPtr
	local nCurs		as	IntPtr
	local nRet as dword[/b]	
	
	
	local adsBlock as codeblock
	local successBlock as codeblock
	local errorBlock as codeblock
	
	adsBlock := { | |



		if self:lCursorAktiv
			XSharp.RDD.Functions.AdsCloseSQLStatement(self:nStatement) 
		
		endif

		self:lCursorAktiv := true

		self:nAdsRet := XSharp.RDD.Functions.AdsCreateSQLStatement(self:nConnection, @nStat)
	
	
		//Statement ausführen
		self:nAdsRet := XSharp.RDD.Functions.AdsExecuteSQLDirect(nStat, self:cStatement, @nCurs)
	
	
		self:nStatement := nStat
		self:nCursor    := nCurs
	
		return self:nAdsRet
		}
		
	errorBlock := { | adsErrorMessage |
	
		TrissWarning:LogWarning(adsErrorMessage) // TODO vielleicht sollte man stattdessen eine Exception werfen? Siehe nächste Zeile
		// throw TrissFatalException{adsErrorMessage}
		return false
		}
		
	successBlock := { | |

		
		self:nAdsRet  := XSharp.RDD.Functions.AdsGetRecordCount(self:nCursor, ADS_IGNOREFILTERS, @nRet)
		self:nLastRec := nRet

		self:CreateStruct()
		return true
	}
	
	dbAdsServer:WrapAds(adsBlock, successBlock, errorBlock)
	return true
This code crashes in 2.12.2 and worked up to 2.11.0.1.

Moving the declaration inside the block it works now also with 2.12.2.

Code: Select all

method Execute()	

	local adsBlock as codeblock
	local successBlock as codeblock
	local errorBlock as codeblock
	
	adsBlock := { | |

[b]		local nStat		as	IntPtr
		local nCurs		as	IntPtr[/b]

		if self:lCursorAktiv
			XSharp.RDD.Functions.AdsCloseSQLStatement(self:nStatement) 
		
		endif

		self:lCursorAktiv := true

		self:nAdsRet := XSharp.RDD.Functions.AdsCreateSQLStatement(self:nConnection, @nStat)
	
	
		//Statement ausführen
		self:nAdsRet := XSharp.RDD.Functions.AdsExecuteSQLDirect(nStat, self:cStatement, @nCurs)
	
	
		self:nStatement := nStat
		self:nCursor    := nCurs
	
		return self:nAdsRet
		}
		
	errorBlock := { | adsErrorMessage |
	
		TrissWarning:LogWarning(adsErrorMessage) // TODO vielleicht sollte man stattdessen eine Exception werfen? Siehe nächste Zeile
		// throw TrissFatalException{adsErrorMessage}
		return false
		}
		
	successBlock := { | |
[b]		local nRet as dword[/b]
		
		self:nAdsRet  := XSharp.RDD.Functions.AdsGetRecordCount(self:nCursor, ADS_IGNOREFILTERS, @nRet)
		self:nLastRec := nRet

		self:CreateStruct()
		return true
	}
	
	dbAdsServer:WrapAds(adsBlock, successBlock, errorBlock)
	return true

Markus
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ADS Rdd EoF function

Post by robert »

Markus,
We had indeed a problem in the codeblock handling in 2.12.2

This is fixed in the upcoming 2.13 release for which we have a compiler fix for our beta testers already.
I have added you to the betatesters list. You should be able to see the download in the Downloads area of this website.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply