Page 1 of 2
ADS Rdd EoF function
Posted: Fri Jun 10, 2022 9:33 am
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
ADS Rdd EoF function
Posted: Fri Jun 10, 2022 9:48 am
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
ADS Rdd EoF function
Posted: Sat Jun 11, 2022 9:03 am
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
ADS Rdd EoF function
Posted: Mon Jun 13, 2022 9:27 am
by robert
Markus,
Check your mail.
I have created a ticket for this:
https://github.com/X-Sharp/XSharpPublic/issues/1054
Robert
ADS Rdd EoF function
Posted: Mon Jun 13, 2022 2:40 pm
by markus.lorenzi@dvbern.ch
Thank you very much for your great support!
ADS Rdd EoF function
Posted: Mon Jun 13, 2022 3:06 pm
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
ADS Rdd EoF function
Posted: Mon Jun 13, 2022 9:23 pm
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
ADS Rdd EoF function
Posted: Tue Jun 14, 2022 7:24 am
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
ADS Rdd EoF function
Posted: Fri Jul 01, 2022 9:00 am
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
ADS Rdd EoF function
Posted: Fri Jul 01, 2022 9:34 am
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