Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)
Suggested answer

Export pictures from Microsoft Dynamics NAV 2009

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

I would like to export pictures from Microsoft Dynamics NAV 2009.

I try to export with the following script :

declare @path varchar(100)= 'C:\Pictures\'

SELECT [Picture]

,@path+[MyID] AS Path

FROM [MyTable]

Files are correctly created with a size which seems to be correct, but the image seems to be crypted, regarding the structure of the file , it is not a jpg, bmp ....

The structure of the files begins like this :

0x01447C5A1A2886BEC7BD0AF5B2..... ...

Thank you in advance for you help

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Export pictures from Microsoft Dynamics NAV 2009

    Thank you for your help

  • Suggested answer
    Roberto Stefanetti Profile Picture
    Roberto Stefanetti 12,998 on at
    RE: Export pictures from Microsoft Dynamics NAV 2009

    hi,

    I know that does not solve the problem but I'll give you some links and examples

    BLOB Fields

    If you are using NAV BLOB Fields; by default the Compressed property is <Yes>, which means the value is zipped and not usable externally; Change this property to No and the value will be the binary of a normal bitmap format (provided that is whats stored there) which you can extract and display externally.

    Some samples & links

    NAV export samples:

    //EXPORT

    // export blobs as bmp files

    CALCFIELDS(Picture);

    IF Picture.HASVALUE THEN BEGIN

       PictureFileName := FormatFileName(FilePath,Item."No.");

       Picture.EXPORT(PictureFileName,FALSE);

    END;

    //STREAM

    tem.GET('1000');

    item.CALCFIELDS(Picture);

    IF item.Picture.HASVALUE THEN

       BEGIN  

          Item.PICTURE.CREATEINSTREAM(InStrm);  

          DOWNLOADINTOSTREAM(InStrm, 'Save  image', 'E:\', '*.bmp', '');

      END;

    Form 346 ...

    IF Picture.HASVALUE THEN

     Picture.EXPORT('*.BMP',TRUE);

    CODE\ENCODE64

    Use Encode\Decode 64 functions to convert a BLOB to Base64

    ex: Codeunit 99008516 - BizTalk XML DOM Management

        Function 'GetPicture' converts a Base64 encoded DOM node to binary and imports it into a BLOB.  

        Function 'AddPicture' converts a BLOB to Base64 encoding and adds it to an XML doc...

    You can use Encode\Decode 64 functions on sql server stored procedures, views, sql scripts

    Basically, a BLOB field in NAV contains a byte-array, so the challenge is how to read or write this byte-array and use it in the conversion methods. In .Net we can use Stream objects to work with byte-arrays.

    .NET Base64 encoding\decoding

    To convert a Base64 string to binary data, we can use the "Convert.FromBase64String" method. It accepts a string as input parameter and returns a converted byte-array.

    To convert binary data to a Base64 string, we can use the "Convert.ToBase64String" method. It accepts a byte-array and returns a Base64 encoded string.

    To exchange binary data in a web service, it is common use to convert the binary data to Base64 encoding. The .Net Framework has built-in support for Base64 converting with the System.Convert class.

    Good link this:

    www.kauffmann.nl/.../binary-data-with-nav-web-service

    How to import and export BLOB fields using Dataports in Navision

    support.microsoft.com/.../874348

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans