Options

populating blob field in navision from C++

jksjks Member Posts: 277
Hi all,

I want to store a .bmp file to navision(field in navision is of type blob) from C++ program. How can i do that?

Is it possible to do this with cfront?
I am not able to use DBL_BLOB data type in cfront. I have declared one variable of type DBL_BLOB. but it gives me a compile time error that
DBL_BLOB undeclared identifier.

Please help.

Comments

  • Options
    janpieterjanpieter Member Posts: 298
    probably by just saving the bmp to a file and import it with C/AL code. 8)

    Probably you CAN do this when using MSSQL server ... i think this is well documenten somewhere in MSDN. (i once did this for MySQL and that was quite easy).

    I think the DBL_BLOB datatype wont do the trick try and have a look at stream objects.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    kinekine Member Posts: 12,562
    Warning! BLOB field in Navision is compressed by default. If you want to save data through external components, you must disable this compression on the field in Navision. Else you will get error about wrong compression in Navision... if you disable this property, you can save the data as standard BLOB data and use them in Navision...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    Hello Kine,

    I have disabled compression. But still i don't know how to store blob data(picture image) from c++ application to navision.


    Please help.
  • Options
    kinekine Member Posts: 12,562
    It depend on which component you want to use for communicating with MS SQL server. ODBC, ADO etc. And you must learn how to work with this components... but sorry, this is not C++ forum... Navision part is ready, you must ask C++ experts how to work with MS SQL blob fields...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    jksjks Member Posts: 277
    Thanks kine for your help.
  • Options
    kinekine Member Posts: 12,562
    And sorry, I forgot that you want to write the blob through C/Front - in this case you do not need to disable the compression, and it is not case for C++ experts... you are on right place... sorry to confusing you...

    I have only example for VB, not for C++... and in VB is not problem the types of the variables, but you can be inspired by the code...
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   8565
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   14775
       LinkTopic       =   "Form1"
       ScaleHeight     =   8565
       ScaleWidth      =   14775
       StartUpPosition =   3  'Windows Default
       Begin VB.CommandButton Command1 
          Caption         =   "Command1"
          Height          =   4095
          Left            =   2160
          TabIndex        =   0
          Top             =   1320
          Width           =   9375
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Sub Command1_Click()
    Dim hTable As Long
    Dim hRec As Long
    Dim picture1 As Variant
    Dim picture2 As Variant
    Dim name As Variant
    Dim cf As CFRONT
    Set cf = New CFRONTlib.CFRONT
    cf.CFrontDllName = "cfront.dll"
    cf.SetNavisionPath "c:\Program Files\Navision Attain\Client"
    
    cf.OpenDatabase "c:\Program Files\Navision Attain\Client\database.fdb", 1000, 1
    cf.OpenCompany "CRONUS International Ltd."
    cf.OpenTable hTable, 5200
    hRec = cf.AllocRec(hTable)
    If cf.FindRec(hTable, hRec, "-") = True Then
        cf.BWT
        picture1 = cf.GetFieldData(hTable, hRec, 19)
        cf.EWT
    End If
    
    If cf.FindRec(hTable, hRec, "+") = True Then
        cf.BWT
        cf.AssignField hTable, hRec, 19, picture1
        cf.ModifyRec hTable, hRec
        cf.EWT
    End If
    
    MsgBox "ok", vbOKOnly, "ok"
    
    cf.FreeRec hRec
    cf.CloseTable hTable
    cf.CloseDatabase
    
    End Sub
    
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.