web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)
Suggested Answer

Export pictures from Microsoft Dynamics NAV 2009

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Roberto Stefanetti Profile Picture
    12,998 on at

    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

  • Community Member Profile Picture
    on at

    Thank you for your help

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans