03-26-2013 11:32 AM
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
Solved! Go to Solution.
03-26-2013 12:10 PM
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.
03-28-2013 08:16 AM
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/