January 2008 Archives
Problem: In SSIS, you want to update a variable from a Script Component embedded in a Data Transform task. You get an error message reading "the collection of variables locked for read and write access is not available outside of postexecute". What's up?
Problem: You have some XML, and you need to validate it against a custom schema that you want to deploy with your .Net 2.0 assemblies. Issues addressed: opening the file and handling the schema validation.
Solution: The XmlSchema class contains a Read method that takes a stream as a parameter. Nicely matching up to that, you can open a stream from an embedded resource (thank you, attilan.com).So, embed the schema. In Visual Studio's Solution Explorer, right-click the schema file and choose properties. Change the Build Action to "Embedded Resource".
Problem: you have image data from an HTML e-mail, but don't know what to do with it. When you save it to disk it comes out with a weird string instead of binary data.
Solution: pretty simple, you just have to know the terms. This string of data is actually Base64 encoded, which means that the binary data has been converted to a text string for easy transmission over text protocols. .Net Developer's Journal has a good full explanation. All you have to do is convert the string over to a byte array using Convert.FromBase64String, then save your new byte[].