Okay, so I am migrating away from Bullhorn at the moment. Bit of a shame that the email messages are in an unusual format but never mind I guess. I have the following code which successfully reads the fields from the database and outputs the uncompressed data to the console.
From there, I wanted to store this uncompressed text as a Variable called UnCompBody (which is fine) and then UPDATE this back in to the database in to a new column called commentsUnCompressed - this is where it falls down because the compiler reads the HTML in the uncompressed message bodies as code and since the characters are not escaped and it's reading the first " as the end of the string.
I'm not quite sure where to go from here or whether this is the right strategy to go down.... any help would be much appreciated.
By the way, although InflateToString2 is no longer used, you can use UnzipToString instead.
Here's my code:
Code: Select all
static void Main(string args)
SqlConnection conn = new SqlConnection("Data Source=PENTHOUSEWIN8;Initial Catalog=BULLHORN1755;Integrated Security=True");
SqlCommand cmd = new SqlCommand("SELECT commentsCompressed from bullhorn1.BH_UserMessage where userMessageID = 1508", conn);
SqlDataReader reader = cmd.ExecuteReader();
Byte bytes = null;
bytes = new Byte[(reader.GetBytes(0, 0, null, 0, int.MaxValue))];
reader.GetBytes(0, 0, bytes, 0, bytes.Length);
Console.WriteLine("Read " + bytes.Length + " bytes from database.");
Chilkat.Zip zip = new Chilkat.Zip();
Chilkat.ZipEntry entry = zip.AppendCompressed("test.txt", bytes);
unCompBody = entry.UnzipToString(0, "UTF-8");
SqlCommand cmdcs = new SqlCommand("UPDATE bullhorn1.BH_UserMessage SET commentsUnCompressed = '"+unCompBody+"' WHERE userMessageID = 12" , conn);
Console.WriteLine("I'm finished, press any key");