Hello,
currently I try to import the value of a decimal field from a SQL database into a Navision database. I usually do this via ado recordset and a variable of type Variant. For decimal fields this does not seem to go if I have understood correctly because of the fact that the SQL decimal field are float 9-bit, whereas in the case of Navision decimal fields it is 8-bit float. I have therefore tried to convert the decimal decimal fields before the import with cast, or convert into the appropriate format, without success. It seems as if Navision failed in the mere attempt to read the value of the SQL decimal fields somehow somewhere. Here is the corresponding code:
GtxSQLStatementWeight: = STRSUBSTNO (gTxSELECT, '*' + ',' + convert (decimal (5,2), [max_ LoadingWeight]) ',
gTxT_ExportOrderHead,
gTxT_ExportOrderHead_Print, 1,
gTxT_ExportOrderHeader_IsPrint,
0);
gatADORecordSet3.Open (gtxSQLStatementWeight, gatADOConnection, ginOpenMethod, ginLockMethod);
EVALUATE (lvaVariant, gatADORecordSet3.Fields.Item (FORMAT (gTxT_ExportOrderHead_maxWeight)) Value);
With the SQL statement I open the recordset and try to convert the field max_ Loading Weight into a decimal data field with 2 decimal places. Then I try to use EVALUATE to transfer the value of the (converted) field max_Loading Weight to the variable lvaVariant. Here the debugger shows that the EVALUATE fails; For the value of the variable lvaVariant, "Value" is displayed instead of the actual numeric value, if I interpreted it properly hides behind it an undefined value. Attempts to convert the decimal field into a field of type money or float also fail.
I have tried it with a stream (more specifically 'Microsoft ActiveX Data Objects 2.8 Library'.Stream and a field' Microsoft ActiveX Data Objects 2.8 Library'.Field 'adField):
GvdReadADOFieldDec (adField: Automation "'Microsoft ActiveX Data Objects 2.8 Library'.Field") DecimalValue: Decimal
CREATE (Adstream, FALSE, TRUE);
adStream.Open;
adStream.WriteText (FORMAT (adField.Value));
AdStream.Position: = 0;
IF EVALUATE (DecimalValue, adStream.ReadText) THEN;
The WriteText method fails here.
What I've noticed is that when I look at the contents of the max_load weight field directly in the SQL Server Management Studio, 20 decimal places are displayed, the actual decimal places are displayed, the rest is filled with zeros. Is this possibly the problem, and how can it be solved? As I said before, any attempt to access the value of the field from the Navision page fails.