how to set the length in an xml file?

how to set the length in an xml file?



I need to set the length of the ContractId field to 25 max. how can I do that?
in other way can I use the substring and how can I use I tried to use it but it works find when the field has value but when the field has no value it throws error so I wonder how can I use substring without causing this error.


new XElement(ns + "projectInfo",
new XElement(ns + "awardingBody", string.Empty),
new XElement(ns + "contractAgencyID", String.Empty),
new XElement(ns + "contractAgency", IsLcpCertified ? (certStatusRecord.ContractorProject.IsSub == true ?
certStatusRecord.ContractorProject.PrimeContractorName : certStatusRecord.ContractorProject.AwardingAgency) :
certStatusRecord.ContractorProject.PrimeContractorId == null ? accountName : certStatusRecord.ContractorProject.PrimeContractor.Name),
new XElement(ns + "projectName", ""),
new XElement(ns + "projectID", certStatusRecord.Project.DIRProjectId),
new XElement(ns + "awardingBodyID", ""),
new XElement(ns + "projectNum", ""),
new XElement(ns + "contractID", **certStatusRecord.ContractorProject.ContractId**),
new XElement(ns + "projectLocation",
new XElement(ns + "description", ""),
new XElement(ns + "street", ""),
new XElement(ns + "city", ""),
new XElement(ns + "county", ""),
new XElement(ns + "state", ""),
new XElement(ns + "zip", ""))),
new XElement(ns + "payrollInfo",
new XElement(ns + "statementOfNP", certStatusRecord.Performing == "YES" ? false : true),






Please show us what you tried, and the error you got when you tried it. Also tell us the data type of certStatusRecord.ContractorProject.ContractId.

– Dour High Arch
Sep 9 '18 at 18:53



certStatusRecord.ContractorProject.ContractId






Are you using a schema? String.Empty should work when there is no schema. So the error must be coming from a schema.

– jdweng
Sep 9 '18 at 20:13






the field is (varchar (50), null)

– Nivo
Sep 10 '18 at 16:01




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)