I have developed a third party integration that pushes data out to SQL staging tables and pulls data from staging tables.
One of the tables I am trying to read from contains a Customer Signature. It is stored as an Image Datatype within SQL and seems to be identical to the way Navision stores BLOB files within Sql.
The third party provider assures me that the file is stored as a Bitmap.
I am trying to pull this data from SQL and store it into a BLOB file in a Navision staging table. I open up the connection to the SQL database, but I cannot seem to figure out how to grab that piece of data. All of my other routines work correctly (grabbing fields with types of Code, Text, Decimal, etc.), but I cannot grab the Image withour receiveing an error.
Any suggestions?
Thanks,
Larry
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
You can use ADO RecordSet to solve this.
I assume, that you already are using ADO to read records from the mentioned table. If Yes, then you can use ADO RecordSet to read the image.
There are 2 ways - as already mentioned by kine.
1) Stream the image to a file and then afterwards import it into the blob.
The Stream can be done by using ADO Stream.
I guess you know how to import a file into a blob ;-)
2) Another way is to move/insert the image into your table by using ADO RecordSet. Create 2 connections, one to your image table (ADOConn) and one to the table in Navision (NAVconn) where you want the picture to be inserted. Then "transfer" the Value from one RecordSet to another and Add it.
Hope this helps :-)
My techblog
Meet me @ LinkedIn
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
If you try it - your code will not fail. Everything will look ok - but when you try to export /read your blob field it will get an error.
Therefore in case of compressed fields, I would use the first way.
Btw. I can see, that I have posted a wrong code to the first way... so here is the correct code ;-)
It is important that the Type is set at first or else you will not be able to read the image as a binary file. If Type is set after Open, you will read the image as Text - and this will not always work.
My techblog
Meet me @ LinkedIn
For one who want to read more about ado stream :
http://msdn.microsoft.com/en-us/library ... 32(v=vs.85).aspx
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
save image to file using bcp where dbname is nav database and objexp is a table with one image column - for the export template
remove first 8 bytes which are probably the size
deflate the stream like this (powershell code):
since this is all supported in .net, can be done fully in c#