Conversion Error - string but value coming through is a number

0
Adam_Piper posted this 17 September 2021

I have a column in a database that is a varchar datatype and in docentric we are passing it through as a string but where the data is just a number I am seeing conversion error on the documents when created.

I have tried forcing the data to be varchar using CAST, Convert and STR in the storedprocedure creating an XML but this still happens.

Is anyone able to advise of some options to try and fix this issue at all?

1 Posts
1 Points
1 Comments
Order By: Standard | Newest | Votes
0
jles posted this 17 September 2021

Adam,

Thank you for reporting the issue. The problem seems to be in the fact that you don't have an XSD. When you use the "Infer schema from sample XML" functionality, Docentric Add-In for MS Word tries to infer the schema from that XML. In XML everything is string and the Add-In tries to be "clever" and "infers" the data type from the XML string value. For example, when a string value consists only of digits, it will guess the type is integer or perhaps double if the decimal delimiter is present. In your case, its guess is wrong.

There is one solution to this problem: you need to generate the XML schema (XSD) and use it in the Add-In. You can use Visual Studio for that. Visual Studio will most probably make the same mistake, so you will need to manually fix the mistakes.

There is also a workaround: Instead of generating an XSD, you can traverse through the generated sample XML and manually change the string values so that they don't represents numbers anymore.

Let me know if this helps.

Best regards,

Jure

154 Posts
294 Points

Our 225992 members have posted 342 times in 101 discussions