Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

VB script error Expand / Collapse
Author
Message
Posted Monday, November 26, 2012 8:32 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 6:16 AM
Points: 558, Visits: 1,737
Hello,

I am trying to upgrade an SSIS package to 2008. The package includes a Script task editor with the following code:

---------------------------------------
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports java.util.zip
Imports java.io


<System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
<System.CLSCompliantAttribute(False)> _
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum

' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.


Public Sub Main()
Try
Dim strSourceFile As String
Dim strDestinationDirectory As String
strSourceFile = "C:\Visio2020Upload\" & Dts.Variables("file").Value.ToString()

strDestinationDirectory = "C:\Visio2020Upload\"
Dim oFileInputStream As New java.io.FileInputStream(strSourceFile)
Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
Dim bTrue As Boolean = True
Dim sbBuf(1024) As SByte

While 1 = 1
Dim oZipEntry As ZipEntry = oZipInputStream.getNextEntry()
If oZipEntry Is Nothing Then Exit While
If oZipEntry.isDirectory Then
If Not My.Computer.FileSystem.DirectoryExists(strDestinationDirectory & oZipEntry.getName) Then
My.Computer.FileSystem.CreateDirectory(strDestinationDirectory & oZipEntry.getName)
End If
Else
Dim oFileOutputStream As New java.io.FileOutputStream(strDestinationDirectory.Replace("\", "/") & oZipEntry.getName())
While 1 = 1
Dim iLen As Integer = oZipInputStream.read(sbBuf)
If iLen < 0 Then Exit While
oFileOutputStream.write(sbBuf, 0, iLen)
End While
oFileOutputStream.close()
End If
End While
oZipInputStream.close()
oFileInputStream.close()


Catch ex As Exception
Throw New Exception(ex.Message)


End Try


End Sub


End Class
---------------------------------------

I get the following errors when I try to build the code:

Type 'ZipEntry' is not defined.
Type 'java.util.zip.ZipInputStream' is not defined.
Type 'java.io.FileInputStream' is not defined.
Type 'java.io.FileOutputStream' is not defined.

Does someone know if there is a substitute I can use for java.util.zip and java.io ?

Thanks,
Paul
Post #1388657
Posted Monday, November 26, 2012 8:48 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:44 AM
Points: 12,910, Visits: 32,015
those two dll's, java.util.zip.dll? and java.io.dll? need to be in the same folder as the script you are calling.

they probably are not,and i'm not sure how to insert them into the global assembly cache so you don't need them locally.





Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1388664
Posted Tuesday, November 27, 2012 2:22 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Yesterday @ 6:16 AM
Points: 558, Visits: 1,737
Lowell (11/26/2012)
those two dll's, java.util.zip.dll? and java.io.dll? need to be in the same folder as the script you are calling.

they probably are not,and i'm not sure how to insert them into the global assembly cache so you don't need them locally.


Thanks for your reply. I was wondering if you knew how to replace java.io with System.IO and and java.util.zip with ??? (another System function) and then inherit their functionality below in the code ?

in other words:
how can I replace 'Imports java.io' with System.IO and 'Imports java.util.zip' with some other applicable System.??? and then inherit their functionality by replacing the codes below with appropriate System.??? versions :


Dim oFileInputStream As New java.io.FileInputStream(strSourceFile)
Dim oZipInputStream As New java.util.zip.ZipInputStream(oFileInputStream)
Dim oZipEntry As ZipEntry = oZipInputStream.getNextEntry()
Dim oFileOutputStream As New java.io.FileOutputStream(strDestinationDirectory.Replace("\", "/") & oZipEntry.getName())

I do not use and write VB scripts so I am not sure if I am able to explain my situation clearly.

Thanks,
Paul
Post #1389020
Posted Wednesday, November 28, 2012 6:27 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, August 21, 2014 4:21 AM
Points: 561, Visits: 1,168
I've found that sometimes as well as declaring Imports system.IO (or whichever I need), I have to actually add a reference to it. Open up the script in the editor then use Project, Add Reference and find the appropriate one in the lists and add it.
Post #1389702
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse