reading value of type image from sql server

jks
Member Posts: 277
Hi all,
I want to retrieve a value of type Image(blob in navision) from sql table and want to assign that value to one text variable( my blob contains only characters)
for that i have declared variables of type automation.
I chose following Automation Server
'Microsoft ActiveX Data Objects Recordset 2.5 Library'
CREATE(varrecord);
strsql:='select * from "Windowmaker Software Limited$Licence" where "Record id"=1';
strconnection:= 'Provider=SQLOLEDB;User Id=xyz;Password=xyz;Data Source=IM33;DATABASE=Navision Demodatabase';
varrecord.CursorType(0);
varrecord.CursorLocation(1);
varrecord.Open (strsql,strconnection);
varfield:= varrecord.Fields;
varfieldobj:= varfield.Item(19);
textvar:=varfieldobj.value; // gives an error here
Do i need to create a stream?
Please help.
I want to retrieve a value of type Image(blob in navision) from sql table and want to assign that value to one text variable( my blob contains only characters)
for that i have declared variables of type automation.
I chose following Automation Server
'Microsoft ActiveX Data Objects Recordset 2.5 Library'
CREATE(varrecord);
strsql:='select * from "Windowmaker Software Limited$Licence" where "Record id"=1';
strconnection:= 'Provider=SQLOLEDB;User Id=xyz;Password=xyz;Data Source=IM33;DATABASE=Navision Demodatabase';
varrecord.CursorType(0);
varrecord.CursorLocation(1);
varrecord.Open (strsql,strconnection);
varfield:= varrecord.Fields;
varfieldobj:= varfield.Item(19);
textvar:=varfieldobj.value; // gives an error here
Do i need to create a stream?
Please help.
0
Comments
-
A stream would be the easiest,fasted working and most beautiful solution.
If you work with a version that hasn't streams, you can write the BLOB to disk. Then open it with a File-variable and read it into your text-variable.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Warning! If you are reading BLOB through SQL (without using C/AL), you will get compressed data... If you want to read BLOB without using Navision (or using Navision but reading through other tools) you need to disable compression of the field.
I am not sure if it is applicable to your case but...0 -
How can i store blob to the disk?
How can i create stream using varfieldobj, because that is the variable refering to the column of the table?0 -
Store BLOB to disk:
example with field Picture of Item-tableIF recItem.Picture.HASVALUE THEN BEGIN recItem.CALCFIELDS(Picture); recItem.Picture.EXPORT(txtFilename,FALSE); END;
PS : if the BLOB-field in SQL in NOT a Navision-table, you need to create a Navision-table that points to that table (Table Property : "LinkedObject")
Or instead of doing this:textvar:=varfieldobj.value; // gives an error here
try this:BLOBvar := varfieldobj.value;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
How to declare a variable of type blob?
because when you see the drop down menu in c/al globals blob is not there.
Thanks for any help0 -
Use a record where a Blob is present (like Item or Object).Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hello Kriki
Can you please explain your point in some detail? I am not able to understand it.0 -
Define a global of type record with subtype "Item".
In the Item-table, there is a field "Picture". This field is a BLOB-field.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
According to your suggesting i made one entry in c/al globals as below:
blobvar Record Item
then if i write
blobvar:=varfieldobj.value
then it gives an run time error that multiple-step oledb generated errors.0 -
Create a file as binary for writing. Then write your variant in it.
filMyFile.WRITE(varfieldobj.value);
then close the file.
Open the file with a text-editor to see if it has been written correctly.
If it is written correctly you can open the file to read and put everything directly in a text-variable.
Other possibility is still to create a Navision table with the same layout as the SQL-table and connect the Navision table directly to the SQL-table. In this case you can do a find for the record and you have it in your BLOB. Store that on disk and then open the file to read and put everything directly in a text-variable.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions