Script Component: Working With BLOB
Jan 8, 2008
I have few tables that I need to export to an MS Access database each day to send off to the customer. In these tables I have a few columns that I need to strip all the HTML out of before they are put into Access since Access does not display the formatting correctly. Some of the fields are varchar and some are text, but all of the fields that are varchar are over 255 in size, so this forces me to use Access' Memo type for both.
In SQL 2000 I used the ActiveX Script to modify these fields, stripping out the HTML, and it gave me no complaints. In SQL 2005, I am adding a Script Component into the Data Flow before the Destination and adding the script in there. So far so good. The problem arises when I try to retrieve and update the data in these fields because they are treated as BLOB data. I believe what I need to do is to retrieve the Byte array from the row using the GetBlobData(), then convert that to a string, strip out the HTML, convert back to a Byte array, then clear the original value using the ResetBlobData(), and then update the field using the AddBlobData. I think?
I am not even sure that my code below is converting the byte array into a string correctly. If I throw a Messagebox in there to see what it has for the string, it just gives me the first character in the field. But even ignoring that, the package will not execute and I am stumped.
The error I now get is:
Array cannot be null.
Parameter name: bytes
Code Block
''-----------------------------------------------------
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim b As Byte()
If (Row.ProjectDescription.Length > 0) And (Not (Row.ProjectDescription_IsNull)) Then
b = Row.ProjectDescription.GetBlobData(0,CInt(Row.ProjectDescription.Length))
End If
Dim str As String
Dim enc As New System.Text.ASCIIEncoding()
str = enc.GetString(b)
str = RemoveHTML(str)
b = enc.GetBytes(str)
Row.ProjectDescription.ResetBlobData()
If b.Length > 0 Then
Row.ProjectDescription.AddBlobData(b)
End If
End Sub
''-----------------------------------------------------
View 3 Replies
ADVERTISEMENT
Jan 3, 2008
I have few tables that I need to export to an MS Access database each day to send off to the customer. In these tables I have a few columns that I need to strip all the HTML out of before they are put into Access since Access does not display the formatting correctly. Some of the fields are varchar and some are text, but all of the fields that are varchar are over 255 in size, so this forces me to use Access' Memo type for both.
In SQL 2000 I used the ActiveX Script to modify these fields, stripping out the HTML, and it gave me no complaints. In SQL 2005, I am adding a Script Component into the Data Flow before the Destination and adding the script in there. So far so good. The problem arises when I try to retrieve and update the data in these fields because they are treated as BLOB data. I believe what I need to do is to retrieve the Byte array from the row using the GetBlobData(), then convert that to a string, strip out the HTML, convert back to a Byte array, then clear the original value using the ResetBlobData(), and then update the field using the AddBlobData. I think?
I am not even sure that my code below is converting the byte array into a string correctly. If I throw a Messagebox in there to see what it has for the string, it just gives me the first character in the field. But even ignoring that, the package will not execute and I am stumped.
The error I now get is:
Array cannot be null.
Parameter name: bytes
''-----------------------------------------------------
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim b As Byte()
If (Row.ProjectDescription.Length > 0) And (Not
(Row.ProjectDescription_IsNull)) Then
b = Row.ProjectDescription.GetBlobData(0,
CInt(Row.ProjectDescription.Length))
End If
Dim str As String
Dim enc As New System.Text.ASCIIEncoding()
str = enc.GetString(b)
str = RemoveHTML(str)
b = enc.GetBytes(str)
Row.ProjectDescription.ResetBlobData()
If b.Length > 0 Then
Row.ProjectDescription.AddBlobData(b)
End If
End Sub
''-----------------------------------------------------
View 4 Replies
View Related
Apr 8, 2008
I have a blob which is essentially an email and I need to replace all carriage returns in the blob with a special character ("€°"). But it does not work. Please advice.
Dim intBlobLen As Integer = Convert.ToInt32(Row.body.Length)
Dim intFinish As Integer = intBlobLen - 1
Dim bytBlob(intFinish) As Byte
bytBlob = Row.body.GetBlobData(0, intFinish)
Dim strBlob As String = System.Text.Encoding.Unicode.GetString(bytBlob)
strBlob = Replace (strBlob,"/n","€°")
If strBlob.Length > 0 Then
Row.body.ResetBlobData()
Row.body.AddBlobData(System.Text.Encoding.Unicode.GetBytes(strBlob))
End If
Please help. Thanks in advance
View 11 Replies
View Related
Mar 21, 2006
I have an SCD that contains a historical output path. If I throw dataviewer in the flow before the SCD, I can see that it should trigger a trip down that lane, but its not. In the advanced editor, all looks good. Anything I can check. BTW, the datatype of the fields that should cause the SCD are datetime.
thanks in advance
View 1 Replies
View Related
Apr 11, 2008
how to evaluate working day through script component in SSIS
I have a data source. I need to verify if the date belongs to working day, if it does belongs to holiday or weekend ,then I need to send that row to the out put table. I think the only way I can verify this working day issue through script component. Can any one give me some idea/thoughts?
You all have a wonderful weekend.
Thanks
View 17 Replies
View Related
Feb 23, 2006
In the code behind the Script Transformation component, neither the MsgBox nor any of the breakpoints seem to work. Am I missing to do something in order for these to get executed?
Thanks.
Andy.
View 3 Replies
View Related
Aug 23, 2007
I have a timestamp column and a username column with default values of getdate and system user in my table and they are defined as not null.
even though i donot use these columns in scd type 2 in wizard
if the columns are not null the scd deosnot work and If the columns are defined null they work
Can anyone please explain or help me with what might be the problem associated with this
View 1 Replies
View Related
Oct 26, 2007
Hello,
I have a package that has a data lfow task. this task imports data from a db2 database (using the IBM Ole DB provider fro db2) and adds it to sql server database table. This package was created on the server. then though version control (using TFS source control) I check out the package on my local machine. and when I open the package I get the foll 3 errors.
Error 1 Validation error. Import Account Num from BMGP_BDR: DTS.Pipeline: The component metadata for "component "DataReader Source" (1113)" could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
Error 2 Error loading BMAG Download Xref Tables - bmag.dtsx: Microsoft.SqlServer.Dts.Pipeline.ComponentVersionMismatchException: The version of component "DataReader Source" (1113) is not compatible with this version of the DataFlow. [[The version or pipeline version or both for the specified component is higher than the current version. This package was probably created on a new version of DTS or the component than is installed on the current PC.]] at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostCheckAndPerformUpgrade(IDTSManagedComponentWrapper90 wrapper, Int32 lPipelineVersion)
Error 3 Error loading BMAG Download Xref Tables - bmag.dtsx: The component metadata for "component "DataReader Source" (1113)" could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
Please advice.
Thank you.
View 7 Replies
View Related
Jan 23, 2007
Hi,
I have a package which reads an Access file from a folder. My connection manager to this file is .NET providers for OledbMicrosoft Jet 4.0 OLE DB Provider.
Package works from my computer. But when I execute it on the server as a SQL Agent job, I get
The component metadata for "component "DataReader Source" (1) could not be upgraded to the newer version of the component. The PerformUpgrade method failed.
I copied the mdb file to a folder on the server which my packages have no problem reading data from.
My packages run under the same domain account as defined in proxies.
Appreciate a help.
Gulden
View 4 Replies
View Related
Aug 1, 2006
We are debating what is industry “best practice� for serving huge numbers of images in an industrial scale website. More directly, which approach produces the best performance and the best scalability? For example, how do sites like ebay, Amazon, and other large sites handle the millions or billions of images they must deal with?
Store as BLOB in sql server?
Store in /images folder and store url text into sql server?
We always assumed that the second approach is what most sites must do. But do they?
One developer on our team maintains that storing one million or more image files in a directory will most certainly result in poor performance, because the server must scan the directory, searching for the correct file, each time a web request is made. The directory is not indexed (?) so performance must eventually suffer.
Other developer counters that storing millions of images as BLOBs into sql server will result in poor performance and HUGE database. An additional layer of access (webserver to sql server, back to webserver, then to client) causes a delay and performance hit.
Who is right? What do the gurus as the world class sites do?
View 2 Replies
View Related
Mar 16, 2007
In a Data Flow, I have the necessity to use a SSIS variable of type €œObject€? inside Script Component and assign to it the content of 'n' variables of string type.
On exiting from the script the variable of type object should contain something like in the following lines:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDDDD
€¦€¦€¦€¦€¦€¦€¦.
€¦€¦€¦€¦€¦€¦€¦.
On exiting from the data flow I will use the variable of type Object in a Script Task, by reading each element in a cyclic fashion.
Is there anyone who have experienced something like this? Could anyone provide any example of that?
Thanks in advance!
View 3 Replies
View Related
Aug 13, 2007
Hi all
I'm into a project which uses a lot of views for joining 2 or more tables. Using the MERGE component in SSIS will be a huge effort coz it only has 2 inputs and I gotta SORT the input too.
Isnt it possible to have a VIEW like component that joins more than 2 tables and DOESNT need sorting??
(I've thought about creating views in database engine but it breaks my data floe in SSIS and is'nt a practical solution)
View 4 Replies
View Related
Mar 30, 2006
I am writing a custom dataflow transformation component and I need to get the name of the preceeding component.
I have been trying to find a way to get a reference to the Package object, MainPipe object or IDTSPath90 object (connecting to the IDTSInput90 of my component) from my component because I think from there I can get to the information I want.
Does anyone have any suggestions?
TIA . . . Ed
View 7 Replies
View Related
Nov 27, 2007
No idea where this bug crept in from. Have been using SSIS for 1.5 years now without hitting this problem.
I had a script component opening an XML document and parsing it using XPATH. I added some code that uses StreamReader / Streamwriter (closing one stream before starting the other). The code works without issue in my C# app.
And it ran without issue 2-3 times in SSIS. Then suddenly after running my package again, the script component says it completes successfully, yet nothing happens. I set a breakpoint on the first line of code - it never hits it. I add a msgbox as the first line of code - and it never displays.
I then close my package / exit out of ssis ... and then re-open it. When i open my script component, all of my code is GONE. All references that I added are gone.
I tried adding the streamreader/writer process to a dll I created from my c# app ... and added the DLL to the package -- same result.
I can reproduce this on 2 different computers.
Anyone experience this problem ? Any idea how to stop it ? Or debug it ?
Here is a slimmed down code sample of what causes the error :
Public Class ScriptMain
Public Sub Main()
Try
Dim xmlDoc As New XmlDocument
xmlDoc.Load("c:ulkasync_86281519_20070628045850225_4.xml")
MsgBox("xmlLoaded") --this doesn't display once the package starts "acting up"
Catch ex As Exception
MsgBox(ex.Message)
UpdateXML("c:ulkasync_86281519_20070628045850225_4.xml", ex.Message)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
Private Sub UpdateXML(ByVal fileName As String, ByVal message As String)
Try
Dim invalidChar As String = message.Trim().Substring(message.Trim().IndexOf("0x"), 4)
Dim rd As StreamReader = New StreamReader(fileName)
Dim xml As String = rd.ReadToEnd()
Xml = Xml.Replace(invalidChar, String.Empty)
xml = xml.Replace("", String.Empty)
xml = xml.Replace("<![CDATA[<![CDATA[", "<![CDATA[")
xml = xml.Replace("]]>]]>", "]]>")
MsgBox("replaced")
rd.Close()
Dim wr As StreamWriter = New StreamWriter(fileName)
wr.Write(xml)
wr.Close()
Dim xdoc As XmlDocument = New XmlDocument()
xdoc.Load(fileName)
Catch ex As Exception
UpdateXML(fileName, ex.Message)
End Try
End Sub
End Class
View 4 Replies
View Related
Dec 15, 2005
I have had an application running successfully in production for two years. In the last three months the app has become a document management system as well. During the addition of images, it was decided that no images would be stored in the database but on the file system. We now have over 500,000 images averaging in size of 92k each. I had to upgraid the raid once and I can only assume that I will again. I am not expecting the image count to exceed 700,000 in the next 6 months; By this time next year, I am expecting 1.2 million.
Should I reconsider storing the images in the database?
If they are stored in the database, what are the effects on performance?
Thanks in Advance
Wes
View 15 Replies
View Related
Nov 11, 2005
Does sql server has the data type similar to BLOB (Binary largerobject)which is available to DB2. BLOB in DB2 can support up to 2 G(variable-length data )if it does have, which one offers better functionalitiesany advice will be greatly appreciated!
View 4 Replies
View Related
May 17, 2006
Hi,One of our third-party software vendors is planning to implement BLOBin their database for storing certain documents. We are not toothrilled about it, since it can be a drain on our resources, but Iwould like to get the expert opinion out there on the pros and cons ofimplementing this.Also, the database is in Full recovery mode and we back up thetransaction log every 15 minutes. We also do a process similar to logshipping. We have two servers to which these transaction logs arerestored to periodically. What will the impact on the transaction logsdue to changes to the BLOB fields.If you could also point me to any resources that talks in detail aboutperformance, backup and recovery in relation to BLOB that would begreat.Thanks in advanceKR
View 3 Replies
View Related
Jul 21, 2006
Hi,
can anyone help ,me out here with some design consideration reguarding importing of BLOB data to a SQL server 2000 using T-SQL statements?
I want to make an import of some documents which are stored in a Access database, to an Ms SQL server 2000. The documents are stored in the access database as a OLE Object, by now I thought of using the base64String function to convert the data from the access field and write it to the T-SQL statements which will written in a text batch file. And then I apply the SQL Convert function something like:
INSERT INTO testBin VALUES(convert(image,'base64sting_encoded'))
go
Does this work? Is it correct what I am doing?
Thanks.
View 4 Replies
View Related
Aug 31, 2007
Can anyone get me pointed in the right direction or even better specific instructions on how to export BLOB's to .JPG's ? They are in SQL 2005 and I have about 1500 that I need to export. I ran across another site that said to use SSIS but I havent had much luck.
View 1 Replies
View Related
Aug 2, 2005
Can someone please show me an example on how to read & write blob data to a Database? For example if I have the query below (Northwind), how do I actually place the blob item in a picture box on a windows form?SELECT Picture FROM CategoriesWHERE CategoryID = 5
View 2 Replies
View Related
Aug 2, 2005
Can someone please give me an example in C# on how to retrieve an Image from a Table and store i into a Picture box on a windows form? In addition, how to insert a blob record into a table as well.
View 4 Replies
View Related
May 26, 2006
What's a good way to work with Blobs and TableAdapters, in terms of declaring compatible column types in SQL Server and DataTable fields?
View 2 Replies
View Related
Oct 22, 1999
We are using DTS to transfer database from 6.5 to 7.0. The data of those tables with text datatype can not be transferred to the server with version 7.0 though the table structure is transferred. The error message we got is "Error at Destionation for Row Number 1. Error encountered so far in this task: 1. query based insertion or updating of BLOB values can not be supported.
The source we use is Microsoft ODBC driver for SQL Server.
Thanks in advance.
Su Ge
View 1 Replies
View Related
Nov 24, 1999
I'm trying to transfer a table from a sql 7 server to an sql 6.5 server. When I try to select OLE db as the destination it gives me an error saying I can't do OLE DB unless I have sql 7.... So I chose ODBC
When it tries to transfer the table I get this error:
QUERY BASED INSERTION OR UPDATING OF BLOB VALUES CAN NOT BE SUPPORTED
what the hell? Is this due to the transfer from 7 to 6.5? How do I get around this?
-----
What I'm trying to do is change the datatype of a table in this 6.5 database from smallint to integer... (I wasn't the idiot that designed this database with a smallint primary key) There is not enough room to copy the table into a new table, and when I ran through the above process it dropped the table and I can't restore it because I'm not the admin. Is there a way of changing the primary key datatype without using up a large amount of database space? or can I do a transfer from 7-6.5 some how?
This is a nightmare... I wish my client would just upgrade to 7 then this would have taken 5 seconds instead of all day long
View 1 Replies
View Related
Oct 26, 2004
Hi,
I know in Mysql one can use a blob field(instead of varchar) to insert big amounts of data into a field - e.g User Notes or Long detailed descriptions
How do I create a field using Enterprise Manager(MSSQL) to be able to handle this amounts of data ???
I can't seem to find the BLOB-option upon creating a field in MSSQL, am I missing something here ???
Many thanks
View 5 Replies
View Related
Feb 26, 2008
Hello,
I currently have a problem with blobs being cut off.
From powerbuilder, I am trying to pull in an image that is stored as a blob. This has always worked fine in our software, until a more recent version, and is now presenting me with this problem. Here are the details...
When the software is installed with a Sybase Database, everything is working great. It pulls in the full size, and there are no problems here.
However, when the software is installed with a SQL Server DB, problems arise.
The main problem: When using a ADO.NET DBMS interface to the SQL Server DB, the select statement is only pulling in 32000 bytes.
Secondary problem: This one may present a problem in the future, if and when i fix the first problem. To narrow it down to see if it was the ADO.NET interface giving me the problem, i connected to the same table on the same server, but using an ODBC interface as opposed to ADO.NET. This gave me the first 32768 bytes.
So a) ADO.NET when interfacing with SQL Server is only giving me the first 32000 bytes in my selectblob statement. I have narrowed it down to ADO.NET, as the code works fine with Sybase, and ODBC interfacing with SQL Server does not limit it at 32000 bytes.
and if I get a solution to that, something may then be limiting the blob read in size at 32768. Maybe, maybe not... but it is happening with ODBC|SQL Server.
Does anyone have any ideas. This is driving me wild. I have pounded google searching for ADO.NET known blob limitations but cannot find anything.
I'm dying here. Anyone who can help me out would be great. Thanks
View 2 Replies
View Related
Feb 5, 2007
What is BLOB field in MS SQL? How to use insert and access from this field?
View 2 Replies
View Related
May 21, 2007
Hi folks,
i have a problem with the result of my query.
There is a colum(a stored BLOB) witch appears like this:
8t¦–XEÄ
ð_JÑ|eÂ?ØÊ/TÅ®0ù¯ó£1XðÃðpŸ8ãÖð'1ª@ˆ8^j֤K§ì©P=@Ÿú‡¿`T)áGä^ÄÞ˜ÖPfìrç(GC=8ȍ?‹T¼²¤÷ôœ1Ogu…J
K £J�8n1+CD"¹¯ÖE°-§¡�0(Ä¡‡6K?=L:Dþfþ¿€s¬ð0ÀçPä]C·Y1ÄÅ¿(ßû‡Tâg@T$û?äþ0¯R@¥8NTÄhÄ“œã17D?i
I have a progam(QMF for Windows) in which i can selcet the colum and can chose bettween hexadezimal and binary.
Now my question: How can i make it works, that it is displayed as hexadezimal directly? An what is that above?
Many thanks in advance!
View 3 Replies
View Related
Jun 8, 2006
Is it possible to import BLOB data using SQL statements stored in a file to an SQL server. Can the actual INSERT statement contain binary data? Or how should I convert the binary data in order to work with an INSERT statement?
Thanks.
View 5 Replies
View Related
Feb 28, 2008
I am using OLE DB source component to read a blob data column from a table. Then I want to Pass this column to a script component,w hich in it's script task should be able to convert it to a string and send it as an email.
I have tried several ways but none seems to work.
Please advise
View 6 Replies
View Related
Jun 13, 2006
Hi,
I have a conversion application which convertts an access database to an sql server(different versions). I'm using stored procedures. The thins is that I export the OLe Object form access to SQL varbinary. what I do is to convert the binary data from the OLE Object to string using ToBase64String. The thing is that when I execute the SQL statement I get the following error:
Error:Operand type clash: text is incompatible with varbinary.
Can anyone tell me what I do wrong and how can I fix this? Thanks.
View 12 Replies
View Related
Jun 13, 2007
I have a table in a SQL Server database that contains a field(data type image) that contains a text file. I'm trying to retrieve this file and save it onto the hard drive. I'm using the code below, but get I get the error 'Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.' at line 11. This code worked fine when I tested it on the pubs database and exporting the logo field out of pub_info. I'm not quite sure why this doesn't work for my database. Can anyone see where I'm going wrong?
1 Dim cn As ADODB.Connection2 Dim rs As ADODB.Recordset3 Dim mstream As ADODB.Stream
4 cn = New ADODB.Connection5 cn.Open("Provider=SQLOLEDB;data Source=server;Initial Catalog=database;User Id='userid';Password='password'")
6 rs = New ADODB.Recordset7 rs.Open("Select * from filesubmissions where bundleId = 'F0000014.bun'", cn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
8 mstream = New ADODB.Stream9 mstream.Type = ADODB.StreamTypeEnum.adTypeBinary10 mstream.Open()11 mstream.Write(rs.Fields("BLOB").Value)12 mstream.SaveToFile("c:export.txt", ADODB.SaveOptionsEnum.adSaveCreateOverWrite)
13 rs.Close()14 cn.Close()
Thanks
View 2 Replies
View Related
Dec 3, 2007
Dear All, I am trying to run the some code which is designed to return an image blob. However it throws an exceptionException Details: System.IndexOutOfRangeException:
ToolbarLogoSource Error:
Line 55: Response.ClearHeaders() ;Line 56: Response.ContentType = "image/gif";Line 57: byte[] arr = (byte[]) sdr["ToolbarLogo"];Line 58: Line 59: Response.BinaryWrite(arr); I can run the sql SP query fine and it returns binary data ok: Does anyone have any pointers I should look at as to why the error is thrown? Do you think my blobs are corrupt? Here is the code: Thank you for takin the time to look public class GetBanner : System.Web.UI.Page { protected System.Web.UI.WebControls.Image Image1; protected void Page_Load(object sender, EventArgs e) { SqlDataReader sdr = null; int brand_id = 0; try { brand_id = Int32.Parse(Request.QueryString["brand_id"].ToString()); } catch (Exception) { // commented below. Since it is a image handleer //Response.Write("<HTML>You must supply a brand_id</HTML>"); return; } { SqlDataAdapter daGetBanner = new SqlDataAdapter(); string connectionInfo = ConfigurationSettings.AppSettings["ConnectionInfo"]; using(SqlConnection dbConnection = new SqlConnection(connectionInfo)) { SqlCommand objCommand = new SqlCommand("usp_get_new_guid_r", dbConnection); objCommand.CommandType = CommandType.StoredProcedure; dbConnection.Open(); sdr = objCommand.ExecuteReader(); while (sdr.Read()) { Response.ClearHeaders() ; Response.ContentType = "image/gif"; byte[] arr = (byte[]) sdr["ToolbarLogo"]; Response.BinaryWrite(arr); Response.Flush(); } sdr.Close(); dbConnection.Close(); } } }
View 1 Replies
View Related