Import Item field into DBase file

HollandPolandHollandPoland Member Posts: 62
Hi everyone! I'm newbie Dynamics Nav programming, I use Dynamics Nav 4.0 SP2, and I need to import into DBase file (*.dbf) some field of Item table. How I can to do this? I've thought to use 2 Automations variables (Microsoft ActiveX Data Objects 2.5 Library), but I've not to find any documentation how I use this ones...
Thank you for your suggest.

Comments

  • garakgarak Member Posts: 3,263
    How are the connectionstrings for DBase: http://www.connectionstrings.com/?carrier=dbffoxpro

    How to use ADO in NAV read this little Tip&Trick: viewtopic.php?f=5&t=23038

    Regards
    Do you make it right, it works too!
  • HollandPolandHollandPoland Member Posts: 62
    After I open the connection, how I can add rows into Dbase file? This code is right?

    repeat
    DBFFile.fields().Item('ITEMCODE').value := Item."No.";
    DBFFile.fields().Item.('DESCRIPTION').value := Item.Description;
    ....
    DBFFile.insert();
    until Item.next = 0;

    Thank you for replies.
  • garakgarak Member Posts: 3,263
    Do you have check your code?

    Which subtype is your variable DBFFile (RecSet?)

    Regards
    Do you make it right, it works too!
  • HollandPolandHollandPoland Member Posts: 62
    garak wrote:
    Do you have check your code?

    Which subtype is your variable DBFFile (RecSet?)

    Regards

    DBFFile Automation 'Microsoft ActiveX Data Objects 2.5 Library'.Recordset
  • garakgarak Member Posts: 3,263
    So, back from Berlin (Boxing Night) .....

    Microsoft ActiveX Data Objects 2.5 Library'.Recordset -> and from where is the function "DBFFile.insert();" <- insert doesn't exist.
    if isclear(ADOConn) then
      create(AdoConn);
    
    //open the connection handle
    AdoConn.Open([BSTR ConnectionString][, BSTR UserID][, BSTR Password][, LONG Options]);
    .....
    .....
    .....
    
    //Open the tablehandle
    AdoRecset.Open(HEREYOURTABLE,HEREADOCONN,[CURSORTYPEENUM CursorType][, LOCKTYPEENUM LockType][, LONG Options]);
    
    .....
    .....
    .....
    
    //recSet.AddNew creates a buffer with empty fields
    AdoRecset.AddNew([VARIANT FieldList][, VARIANT Values]);
    
    .....
    .....
    .....
    
    //RecSet changes must be saved with update
    AdoRecset.Update([VARIANT Fields][, VARIANT Values]);
    

    So, with your solution (AdoRecSet.fields().Item('ITEMCODE').value := Item."No.";) you should use the update command

    Regards
    Do you make it right, it works too!
Sign In or Register to comment.