Script Component: Migrating a BlobColumn in a Text column (MySQL to SQL Server)

Posted: 01/02/2012 by murilomiranda in Reporting Services

Challenge:
Migrate a table in a MySQL database to a table in a database in SQL Server.

Problem 1:
A column of type “Text” on the side of MySQL.
Solution 1:
Create a column of type “Text”, in this case isn’t Unicode, in SQL Server table side.

Problem 2:
In the package, I cannot assign values ​​to respective OutputBuffer column of type “Text” (source for SQL Server). The “ReadOnly error”.
Solution 2:
You should assign values ​​to this type of columns as follows (You should change the encoding type!):

OutputBuffer..AddBlobData(Encoding.Default.GetBytes(“<SOME_STRING>”);

Problem 3:
How to read the contents of a “Text” column type (in MySQL side), returning a String?
Solution 3:
The following strategy should be used:

string str_notes = System.Text.Encoding.Unicode.GetString(Row.<COLUMN_NAME>.GetBlobData(0, Convert.ToInt32(Row.<COLUMN_NAME>.Length)));

 

I hope it helps and save you time ;)

 

 

Comments
  1. Romaine says:

    This is exactly an issue I must find more information about, appreciate the blog post.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>