How to use Microsoft ActiveX Data Objects 6.0 Library

iris2009iris2009 Member Posts: 56
Hello,

how can I use 'Microsoft ActiveX Data Objects 6.0 Library' in Navision? Where can I find a documentation about it?
I need to read data from Access-Tables.
And I have a specific question: How do I define a "stringformatenum" in nav?? Its the first parameter in the Recordset.GetString()-Function...
or is there another way to read data from rows/fields in a Nav table?

Thanks, Iris

Comments

  • markborgesmarkborges Member Posts: 170
    Hello Iris!

    The ADODB Object (as it is commonly known between developers) is quite easy and straight forward to do what you need.

    Basically you need 4 objects (2 are common to any language, 2 are most common in NAV):

    - Connection
    - Recordset
    - Fields
    - Field

    You must open a Connection in order to use a Recordset.

    So the dataflow should be more or less like this:

    - Open Connection
    - Open Recordset
    - Check if Recordset is not empty
    - Iterate through Recordset
    - Fields = Recordset.Fields;
    - Field = Fields.Items(Name of Field)
    - Field.Value holds the data for that field
    - Close Recordset
    - Close Connection.

    Here is some fast example I could assemble. This probably is not very optimized but it's a starting point for your tests:
    CREATE(oConn);
    CREATE(oRecSet);
    
    oConn.Open('Provider=SQLOLEDB.1;Initial Catalog=Oerlikon;Data Source=abbr0116');
    
    gvStrSQL :=   'SELECT "CONC Contas".Conta, "CONC Contas".Conciliar ';
    gvStrSQL += 'FROM Oerlikon.dbo."CONC Contas" "CONC Contas"';
    
    oRecSet.Open(gvStrSQL, oConn, 1, 1);
    
    IF NOT oRecSet.EOF THEN BEGIN
      oFields := oRecSet.Fields;
      oField := oFields.Item('Conta');
      MESSAGE('%1', oField.Value);
    END;
    
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
Sign In or Register to comment.