can't read integer field from database (ADO)

tommi
Member Posts: 5
Hello,
i try to read a integer field from a database an write it into a field in navision, but i always get error messages.
I tried this:
The Evaluate function also doesn't work:
can somebody help me?
i try to read a integer field from a database an write it into a field in navision, but i always get error messages.
I tried this:
NavTab.Reznr := ADOrs.Fields.Item('Reznr').Value;but i got the message that this type is not supported in C/SIDE
The Evaluate function also doesn't work:
EVALUATE(MischprotokolleMH.Reznr, ADOrs.Fields.Item('Reznr').Value);
can somebody help me?
0
Answers
-
Check that there is no NULL value in the field. You cannot work with the NULL values in NAV and you need to test the field value size before you try to read the value.0
-
The value in the field is never NULL there ist alwas an integer between 1 and 1000.
What do you mean with testing the value size? That it is not bigger than "2147483647"?0 -
No. There is property which tells you how big is the value saved in the field. If it is 0, it means that the value is NULL. If it is different, all is OK... it is used to detect NULL values.
I am not sure, is it really possible to "address" the item through text? Did you try to address the item through integer? (indexing by integer and not text)...0 -
Sorry i'm not so good in Navision programming. I don't realy know, what you mean.
It works fine, when i want to read out a String field from the Database and write it into a String field in Navision:NavTab.Name := ADOrs.Fields.Item('Name').Value;
but i can't find a way to read out an integer and write it into a navision integer field0 -
a field in a database table can have a value assigned to it or it can have no value assigned. The latter is usually reffered to as NULL value
IF your integer type field was never assigned a number then it has no value assigned (has NULL value). NULL and 0 are not the same. Do not expect ADO to retun you value = 0 when the field in question has no value assigned (has NULL value)0 -
today i used this way (thanks Miklos Hollender)
LOCAL PROCEDURE VariantToInteger@50002180(Variant@50002176 : Variant;VAR RetInt@50002175 : Integer) : Integer; BEGIN IF ISCLEAR(ADOStream) THEN CREATE(ADOStream); ADOStream.Open; ADOStream.WriteText(Variant); ADOStream.Position:= 0; EVALUATE(RetInt,ADOStream.ReadText); ADOStream.Close; EXIT(RetInt); END;
possible usage is like that:IF VariantToInteger(ADORs.Fields.Item('Status').Value,OldStatusID2) = OldStatusID THEN
0 -
Thanks Ayhan that works:
New Function:VarianttoInteger(AVariant : Variant) RetInt : Decimal IF ISCLEAR(ADOStream) THEN CREATE(ADOStream); ADOStream.Open; ADOStream.WriteText(AVariant); ADOStream.Position:= 0; EVALUATE(RetInt,ADOStream.ReadText); ADOStream.Close; EXIT(RetInt);
NavTab.Protokoll := VariantToInteger(ADOrs.Fields.Item('Protokoll').Value);
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions