Inserting BLOB into external SQL table

tentacle
Member Posts: 27
Hello,
I am trying to do the following, not very successful until now. Maybe somebody can give me a hint.
Basically I want to create a XML file in Navision and store it into an external table.
1. I do not use XML ports, I am building the XML in a codeunit and store it into a Navision BLOB field. This is done already.
2. Now I want to copy / insert the BLOB field into a remote NON-Navision table on a SQL server.
This is not working as intended.
If I read binary from a file and insert it into the SQL table the field contains the binary characters which are not usable.
ADOStream.Type:=1;
ADOStream.Open;
ADOStream.LoadFromFile(idoc2filename);
ADORecSet.Fields.Item('XMLFIELD').Value :=ADOStream.Read;
ADORecSet.Update;
If I read as text, then the text seems to be too long. Error is (The length of the text string exceeds the size of the string buffer.)
ADOStream.Type:=2;
ADORecSet.Fields.Item('XMLFIELD').Value :=ADOStream.ReadText;
Are there other ways to do this?
Christian
I am trying to do the following, not very successful until now. Maybe somebody can give me a hint.
Basically I want to create a XML file in Navision and store it into an external table.
1. I do not use XML ports, I am building the XML in a codeunit and store it into a Navision BLOB field. This is done already.
2. Now I want to copy / insert the BLOB field into a remote NON-Navision table on a SQL server.
This is not working as intended.
If I read binary from a file and insert it into the SQL table the field contains the binary characters which are not usable.
ADOStream.Type:=1;
ADOStream.Open;
ADOStream.LoadFromFile(idoc2filename);
ADORecSet.Fields.Item('XMLFIELD').Value :=ADOStream.Read;
ADORecSet.Update;
If I read as text, then the text seems to be too long. Error is (The length of the text string exceeds the size of the string buffer.)
ADOStream.Type:=2;
ADORecSet.Fields.Item('XMLFIELD').Value :=ADOStream.ReadText;
Are there other ways to do this?
Christian
0
Comments
-
Solved.0
-
When I wrote "If I read binary from a file and insert it into the SQL table the field contains the binary characters which are not usable." in my first post I already had the solution.
I was not successful in writing the xml as text into the field on the SQL server, so I sticked to the binary. So the next process who is using this field has to decode the binary.
Here is the code I am using now. I divided it into two steps (insert and modify) and there was a reason for it but I do not remember it.
//Create SQL server entry without Blob
SQLString:='INSERT INTO Purchase_Order_Transfer......
ADORecSet.LockType:=3;
ADORecSet := ADOConnection.Execute(SQLString,RecordsAffected,RSOption);
//Now update Blob field
SQLString:='SELECT * FROM Purchase_Order_Transfer where......
ADORecSet.Open(SQLString,ADOConnection,2,3);
//read from file into stream
ADOStream.Type:=1;
ADOStream.Open;
ADOStream.LoadFromFile(idoc2filename);
//Update SQL entry
ADORecSet.Fields.Item('XMLFIELD').Value :=ADOStream.Read;
ADORecSet.Update;0 -
Thanks for sharing! =D>
Tino Ruijs
Microsoft Dynamics NAV specialist0 -
Buen día estimado, tengo una consulta estoy tratando de insertar una imagen a unas BD de nav desde el sql y por transact lo realizó, pero al querer visualizarlo en el mismo navision me sale un error, sabes que debo hacer después se hacer la inserción0
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