xsharp.eu • ADOSERVER strange error on Append: nFieldPosition Invalid or Missing
Page 1 of 1

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Sun Dec 05, 2021 11:51 pm
by jjgregg
I´ve been going through some corruption of sorts using VO2ADO, VO 2.8 sp4b, with [hide]MS SQL 2008 tables... very strange, the error occurs doing simple statements like ADOSERVER:APPEND or FIELDGET and the trapped error using a codeblock to trap the event reads:

[20936] iPointer=1, instantiating oServer
[20936] error trap, append failed, error: nFieldPosition invalid or missing
[20936] ERROR IN NOIVARGET USED

The error occurs when the server is instantiated but the error also occurs calling any method for this server, Append, FieldPut...

local oServer as adoserver
local cbErr as codeblock

cbErr := ErrorBlock({|oErr|_Break(oErr)})
BEGIN SEQUENCE
oServer := BillingTransactions{nil, oConn1, nil, nil, nil }

RECOVER USING uError
oLog:WriteLine( "Could not open oServer, Error: "+uError:description )


Server declaration:
CLASS BillingTransactions INHERIT AdoServer
//{{%UC%}} USER CODE STARTS HERE (do NOT remove this line)

METHOD INIT(sSource, uConn, nCursorType, nLockType, nOptions ) CLASS BillingTransactions
LOCAL i,nFields AS DWORD
LOCAL aFieldDesc AS ARRAY
LOCAL nPos AS INT
LOCAL nMaxRecords AS LONG
LOCAL sRecnoColumn AS STRING
LOCAL lLongFldNam AS LOGIC
LOCAL sStatement AS STRING
//
// Elements of SQL statement
// TableName : BillingTransactions
// ColumnList :
// WhereClause :
// OrderByClause :
//

IF IsNil(sSource)
// Build Select statement
sStatement := "Select * from BillingTransactions"
sSource := sStatement
ENDIF
lLongFldNam := TRUE
nMaxRecords := 0x7FFFFFFF
sRecnoColumn := ""

IF IsNil(nCursorType)
nCursorType := adOpenStatic
ENDIF
IF IsNil(nLockType)
nLockType := adLockOptimistic
ENDIF
IF IsNil(uConn)
uConn := AdoGetConnection()
// The connection in the AdoServer Editor was; ClientConnector
ENDIF

SELF:PreInit()

SUPER:INIT(sSource, uConn, nCursorType, nLockType, nOptions, lLongFldNam)

oHyperLabel := HyperLabel{#BillingTransactions, "BillingTransactions, "BillingTransactions, NULL_STRING}

IF oHLStatus = NIL
nFields := ALen(aFieldDesc := SELF:FieldDesc)
FOR i:=1 UPTO nFields
nPos := SELF:FieldPos( aFieldDesc[DBC_NAME] )

SELF:SetDataField( nPos,;
DataField{aFieldDesc[DBC_SYMBOL],aFieldDesc[DBC_FIELDSPEC]} )

NEXT

SELF:GoTop()
ENDIF

SELF:PostInit()
[/hide]
RETURN SELF

This makes VO2ADO unusable at this point, ADOSERVERs failed selectively, some fail, otthers operate normallly, I can't get a handle on what is going on. HELP

Thanks

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 7:26 am
by robert
John.
To help solve this we need:
- a reproducible example
- the table description (create table statement) + some data for your sql table

We already communicated about this by mail. You told me the problem started after you had to reinstall your software because your machine died.
It must be something in your configurations, but we can only help you find that problem if you provide us with the necessary information.

Robert

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 8:45 am
by lumberjack
Did a quick search on your message and there is nowhere in your code a nFieldPosition variable. I think you looking at the wrong place for the error. Do you have a nFieldPosition column in your table? It seems from the error message you trying to do just that.

HTH

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 11:57 am
by robert
Johan, John,

I suspect that the 'painted' definition of the form that this code is from has
one or more field names that do not exist in the table anymore.
Therefore the line

Code: Select all

nPos := SELF:FieldPos( aFieldDesc[DBC_NAME] )
assigns a value of 0 to nPos
causing the next line

Code: Select all

SELF:SetDataField( nPos,DataField{aFieldDesc[DBC_SYMBOL],aFieldDesc[DBC_FIELDSPEC]} )
to fail.

nFieldPosition is the parameter name inside the SetDataField method.

That is exactly why I asked John a sample and the database definition.

Robert

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 12:12 pm
by jjgregg
Thanks for your reply Robert, the only data field on this table is the TIMESTAMP which is a field that continuously gives me problems because it is automatically updated so it has to be ignored by the application I guess, I am removing the field from the ADOSERVER field listing to see if that helps.

Regards,
John

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 12:40 pm
by robert
John,

The term "datafield" has nothing to do with the Date, DateTime or TImeStamp type.
DataField is a class inside the VO Classes that is used to bind a field in a table to a FieldSpec

Robert

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 12:57 pm
by jjgregg
The server name message is generated when one tries to instantiate the adoserver but only occurs on the first server, strange but it prevents the program from executing and I am really in trouble here... need to have this working ASAP. Thanks.

ADOSERVER strange error on Append: nFieldPosition Invalid or Missing

Posted: Mon Dec 06, 2021 1:08 pm
by robert
John,

I have said this before and this the last time I am saying it: you need to give us more information.

The error message in the BillingTransactions:Init seems to indicate that at the time you created this class there was at least one field name (the field names are stored in the FieldDesc access) that no longer exists in the table at this moment.
As a result the assigment to nPos results in a value of 0, which causes the next line (SELF:SetDataField...) to fail.

Sorry for saying this, but I don't understand why you are so stubborn and refuse to show the data that we need to help you ?
- The SQL table definition
- The complete source code of the BillingTransactions class

Images of error messages are really useless here.
Until you provide us the correct info there is not much that we can do.

Robert