How to get Value from SQL query

kmkaotkmkaot Member Posts: 261
Hi,

Can anybody tell me how to get value from Recordset into my Nav table. I am unable handle if the value is NULL in recordset.

FieldValue:=ADORecSet.Fields.Item('kdate').Value;

where kdate is date and time and sometimes, it is NULL.

Warm Regards
KMK

Comments

  • ara3nara3n Member Posts: 9,256
    Can you change the query and use isnull( kdate,'') as kdate

    ?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kmkaotkmkaot Member Posts: 261
    Thank you

    I have changed query with isnull and query is working fine, still I am getting error at the point of code

    REPEAT
    // Intailize
    Myvar := Myvar +1;
    AttendanceData.INIT;
    AttendanceData.EntryNum:= vlastno;
    AttendanceData.PName:= ADORecSet.Fields.Item('pName').Value;
    AttendanceData.Date:= ADORecSet.Fields.Item('date1').Value; AttendanceData.total:= ADORecSet.Fields.Item('Total').Value;
    {
    IF AttendanceData.total >0 THEN
    BEGIN
    AttendanceData.Intime:=ADORecSet.Fields.Item('Intime').Value;
    AttendanceData.Outtime:=ADORecSet.Fields.Item('Outtime').Value;
    END;
    MESSAGE(FORMAT(ADORecSet.Fields.Item('Total').Value));
    AttendanceData.total:= ktotal ;
    }
    AttendanceData.INSERT;
    vlastno:=vlastno+1;
    ADORecSet.MoveNext();
    UNTIL ADORecSet.EOF();
    ADORecSet.Close();

    and error
    is
    'The length of the text string exceed the size of string buffer'

    can advice pleae

    kmk
  • ara3nara3n Member Posts: 9,256
    ADORecSet.Fields.Item('date1').Value; is returning more that 1024 characters.


    Can you run the query in SQL SMS and see what the values are?

    Also the value returned is a text and you are assigned it to a date type?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • kmkaotkmkaot Member Posts: 261
    Hi all

    I have done it after long support from you. The values are stored VARIANT from SQL query, the type like V-date..................form like VARDATE etc.

    we have get the value from Var*** to Text and Text to date again.

    This it is working.

    I will send code please check

    Warm regards
    KMK
Sign In or Register to comment.