SELECT DocumentBody, MimeType
how to read DocumentBody from sql .
The DocumentBody is a base64 encoded string, so you'll need to convert back to binary and save to a file.
For an online converter see - www.motobit.com/.../base64-decoder-encoder.asp
For doing this in c# use File.WriteAllBytes(@"c:\yourfile", Convert.FromBase64String(yourBase64String));
To do this in SQL is a bit tricky - see blogs.msdn.com/.../converting-from-base64-to-varbinary-and-vice-versa.aspx
Hope this helps!
How did you get on? Did this answer your question?
i am trying to write small API in .Net ...
Then you will need to retrieve the base64 string from the document body and then convert to a binary array and save to a file - see stackoverflow.com/.../converting-a-base-64-string-to-an-image-and-saving-it
I hope this answers your question?
I am working with CRM 4.0 and I had a similar issue where the document body column where it seems to be limited by 43679 and with that it gives me an error about an invalid Base 64 string.
'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.'
It seems the file would have more than that to write on that field as the note was a pdf on this CRM 4 database.
The reason why I am trying to do it via code is to recover a few documents that were deleted but still exist in a earlier day backup.
Any ideas how to recover it?
Business Applications communities