Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 How can I copy and rename file on FTP using SSIS

Author  Topic 

bob12
Starting Member

8 Posts

Posted - 2010-08-19 : 12:23:23
I am doing this in script task. Here is my code. This step is successfull but not doing anything. Can some one help me?

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports Microsoft.VisualBasic.FileIO.FileSystem
Imports System.IO.FileSystemInfo
Imports System.IO
Imports System.Net


Public Class ScriptMain

' 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.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer
Private Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" (ByVal hFtpSession As Integer, ByVal lpszExisting As String, ByVal lpszNew As String) As Boolean

Public Sub Main()

Dim INet, INetConn As Integer
Dim RC As Boolean
INet = InternetOpen("MyFTP Control", 1, vbNullString, vbNullString, 0)
INetConn = InternetConnect(INet, "testserver", 0, "username", "password", 1, 0, 0)
MsgBox(INetConn)
RC = FtpRenameFile(INetConn, "\\inetdir\input.txt", "input.hl7") ' want to move to root directory
InternetCloseHandle(INetConn)
InternetCloseHandle(INet)
Dts.TaskResult = Dts.Results.Success





End Sub
End Class

Thank You

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-19 : 15:42:22
you can easily do this using SSIS elements. Use FTP Task (transfer file) and File Task (to rename it, to copy it)
Go to Top of Page
   

- Advertisement -