AS400 -> ODBC -> ADO

We are building an application which will import data from an AS400. To “speak” with the AS400 we are using the IBM Client Access Express ODBC module. The actual talking is via Microsoft ActiveX Data Objects 2.7 Library where we are using “Connection” and “Recordset”. This works without any problems as long as the fields imported are of datatypes accepted by CSIDE but, always a but, when importing fields of Datatype (in AS400) Zoned Numeric the actual datatype imported is adNumeric (131) and Navision refuses to touch it. Here is extracts from the code used: Connection to the datasource CREATE(ADOConn); ADOConn.Open(‘DSN=AS400SYS;UID=Userid;PWD=Password’); Creating the recordset txtSQL := 'Select * from PFEDIOPH ’ + ‘WHERE HCUNO=’ + FORMAT(recGenJrnLine.“Account No.”) + ’ ’ + ‘AND HCIIV=’ + FORMAT(recGenJrnLine.“Document No.”); CREATE(ADOrs); ADOrs.Open(txtSQL, ADOConn,OpenMethod,LockMethod); ADOrs.MoveFirst; Then when doing Spy := ADOrs.Fields.Item(‘HAM4N’).Value; I got the message: Datatype not supported by CSIDE. I tried a workaround found on the net with a subroutine trying to Unpack the ADO-field: CREATE(adStream); adStream.Open; adStream.WriteText(adField.Value); adStream.Position := 0; IF EVALUATE(DecimalValue,adStream.ReadText) THEN ; where adStream and adField are member of the ActiveX library mentioned above and DecimalValue the return variable. This subroutine is called as follows MESSAGE(‘Value: %1’, ReadADOField(ADOrs.Fields.Item(‘HAM4N’).Value)); but Navision crasches when trying to execute the line. Is there any solution to the problem importing data of datatype daNumeric (131) into navision?? Best regards Jan Karlsson

EVALUATE(Spy, format(ADOrs.Fields.Item(‘HAM4N’).Value));

Hi Jan, Read this topic: http://www.mbsonline.org/forum/topic.asp?TOPIC_ID=8011&SearchTerms=adstream I posted the solution to your problem in that thread. Looking at what you tried before posting (maybe you already read the topic…), I see that you were very close to solving the situation. However, the function ReadADOField has the parameter adField This makes

quote:


MESSAGE(‘Value: %1’, ReadADOField(ADOrs.Fields.Item(‘HAM4N’).Value));


crash Navision as you are passing it adField.Value That function call should be changed toMESSAGE('Value: %1', ReadADOField(ADOrs.Fields.Item('HAM4N'))); I hope you understand what I mean.