Problem extracting Text field from SQL using ADO
iansilvers
Member Posts: 38
I hope someone is able to help.
I am using ADO to access information in an external SQL database, which I use to update a staging table in Navision for later processing. In the SQL database, all the fields that I required are varchar with the exception of one which is a text.
The SQL command I execute to retrieve the recordset is
The Notes field is the text field, and it contains an XML document which I need to get some information out of. I am attempting to write this to a Blob field on my staging table. I can easily process all the fields with the exception of Notes. Using the ActualSize property of the recordset field returns -1 which suggests that it is empty, despite the fact that if I run this command in SQL, it gives me what I expect.
I have tried everything that I can think of, and has been suggested on other topics, but have run into a brick wall. Anyone got any ideas as to what I am doing wrong?
I am using ADO to access information in an external SQL database, which I use to update a staging table in Navision for later processing. In the SQL database, all the fields that I required are varchar with the exception of one which is a text.
The SQL command I execute to retrieve the recordset is
select isnull(tpc_type,'') as Type, isnull(tpc_internal_reference,'') as ClientRef, isnull(tpc_name,'') as ClientName, isnull(tpc_notes,'') as Notes from [dbo].[topics]
The Notes field is the text field, and it contains an XML document which I need to get some information out of. I am attempting to write this to a Blob field on my staging table. I can easily process all the fields with the exception of Notes. Using the ActualSize property of the recordset field returns -1 which suggests that it is empty, despite the fact that if I run this command in SQL, it gives me what I expect.
I have tried everything that I can think of, and has been suggested on other topics, but have run into a brick wall. Anyone got any ideas as to what I am doing wrong?
WHILE NOT Rec.EOF DO BEGIN
Staging.INIT;
Staging."Entry No." := NextEntryNo;
Staging."Unique Reference No." := Rec.Fields.Item('ClientRef').Value;
Staging."Client Name" := COPYSTR(FORMAT(Rec.Fields.Item('ClientName').Value),1,MAXSTRLEN(IKENStaging."Client Name"));
Staging."Last Updated Date" := GetDate(Rec.Fields.Item('LastUpdateDate').Value);
// Status is held in the Notes field which is an XML file
CLEAR(BigText);
ADOStream.Open;
ADOStream.WriteText(Rec.Fields.Item('Notes').Value);
ADOStream.Position := 0;
BigText.ADDTEXT(FORMAT(ADOStream.ReadText),1);
ADOStream.Close;
Staging.Notes.CREATEOUTSTREAM(WriteStream);
BigText.WRITE(WriteStream);
Staging.Processed := FALSE;
Staging.INSERT;
NextEntryNo := NextEntryNo + 1;
Rec.MoveNext;
END;
0
Answers
-
Does it have the same effect when using a "normal" text variable and not a BIGTEXT one?0
-
Alexander Broz wrote:Does it have the same effect when using a "normal" text variable and not a BIGTEXT one?
I tried picking up the first 30 characters of the field into a normal text field, and it was still empty. Anyway, the normal text variable can be a maximum of 1024 characters, and this field in SQL will be much larger than that in most instances, so use of big text is necessary.0 -
Problem solved. Apparently, if you are selecting text fields using ADO, they must appear at the end of the select statement.0
-
iansilvers wrote:Problem solved. Apparently, if you are selecting text fields using ADO, they must appear at the end of the select statement.
Can you post your solution here, I have the same problem. I really don't understand your phrase that "fields must appear at the end of select statement " ?
Thanks a lot0 -
nXqd wrote:iansilvers wrote:Problem solved. Apparently, if you are selecting text fields using ADO, they must appear at the end of the select statement.
Can you post your solution here, I have the same problem. I really don't understand your phrase that "fields must appear at the end of select statement " ?
Thanks a lot
Sorry, but this was a couple of years ago, and I have moved on, so I don't have access to the solution anymore.0 -
If you know and this thread reminds you of something you remember, it'd be great that you help me with my problem

viewtopic.php?f=23&t=53382
Thanks for reading this !0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 333 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