DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Diadem file (image) to database

Solved!
Go to solution

Greetings all,

 

Recently we've found a problem with our application. Instead of exporting report images to a network unit we'll have to save them in a database.

 

Until now, we saved them to a network drive without any problem. We're able to access our database and insert text values from the application, but now we need to save files (images). This is where things become complicated. DIAdem offers a textStream object, but not a inputstream that allows to read a byte array...

 

So, anyone had a problem like this and found a solution? I've found some samples of something similar on NI site, but all of them are for labview...

 

Any help is greatly appreciated,

Tomas

0 Kudos
Message 1 of 3
(5,689 Views)
Solution
Accepted by topic author tlahoz
Sub Base64StringToFile(ByRef vCode, ByVal fullFilePath)
    
  if FileExist(fullFilePath) then
    FileDelete(fullFilePath)
  end if

  Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
  dim oNode : Set oNode = oXML.CreateElement("base64")
  oNode.dataType = "bin.base64"
  oNode.text = vCode
    
  Dim BinaryStream : Set BinaryStream = CreateObject("ADODB.Stream")
  BinaryStream.Type = 1
  BinaryStream.Open
  BinaryStream.Write oNode.nodeTypedValue
  BinaryStream.SaveToFile fullFilePath
    
  Set BinaryStream = Nothing
  Set oNode = Nothing
  Set oXML = Nothing
End Sub

Sub Base64FileToString(ByVal fullFilePath, ByRef vCode)
  
  Dim BinaryStream : Set BinaryStream = CreateObject("ADODB.Stream")
  BinaryStream.Type = 1
  BinaryStream.Open
  BinaryStream.LoadFromFile(fullFilePath)
  
  Dim oXML : Set oXML = CreateObject("Msxml2.DOMDocument.3.0")
  dim oNode : Set oNode = oXML.CreateElement("base64")
  oNode.dataType = "bin.base64"
  oNode.nodeTypedValue = BinaryStream.Read()
  vCode = oNode.text

End Sub

 I used those two methods to read binary file and put it into base64 string. Maybe this helps.

Message 2 of 3
(5,685 Views)

Thank you so much for your help!

 

We were quite lost, and that put us on the right track. With that and a lot of googling, we found the way to do it on http://www.motobit.com/tips/detpg_read-write-sql-image-file/ 

0 Kudos
Message 3 of 3
(5,656 Views)