FTP Script

Posted on 2008-10-29
Last Modified: 2013-11-18
I'm putting this VB code into a DTS package in MS SQL Server 2000.  I pieced it together from other thing I found on the net, but I don't know VB code and am getting an error:

Object Required FTP.

Also other than the fix for that does the rest of the code look ok for doing a transfer from a local file to a ftp server?
ftp.Hostname = ""

	ftp.Username = "User"

	ftp.Password = "Pass"

	' The default data transfer mode is "Active" as opposed to "Passive".

	' Change it to Passive by setting the Passive property:

	ftp.Passive = 1

	'  Establish an AUTH SSL secure channel after connection

	'  on the standard FTP port 21.

	ftp.AuthTls = 1

	'  The Ssl property is for establishing an implicit SSL connection

	'  on port 990.  Do not set it.

	ftp.Ssl = 0

	'  Connect and login to the FTP server.

	connectStatus = ftp.Connect()

	If (connectStatus <> 1) Then

		'MsgBox ftp.LastErrorText


		Main = DTSTaskExecResult_Failure


		dirStatus = ftp.ChangeRemoteDir("RMed")

		If (dirStatus <> 1) Then

		    'MsgBox ftp.LastErrorText


		Main = DTSTaskExecResult_Failure

	End If		




	'MsgBox ftp.getCurrentRemoteDir()


	'specify the file path and name on the local machine

	localInvoiceFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Invoice_RMed.txt"

	localPatientFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Patient_RMed.txt"


	'specify the file path and name on the remote machine

	remoteInvoiceFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Invoice_RMed.txt"

	remotePatientFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Patient_RMed.txt"

	'MsgBox remoteInvoiceFile 

	'MsgBox remotePatientFile


		'download the files from the remote server

		transferStatus = ftp.getFile(remoteInvoiceFile, localInvoiceFile)

		if (transferStatus <> 1) then

			'MsgBox ftp.LastErrorText

			Main = DTSTaskExecResult_Failure


			Main = DTSTaskExecResult_Success

		end if


		transferStatus = ftp.GetFile(remotePatientFile, localPatientFile)

		if (transferStatus <> 1) then

			'MsgBox ftp.LastErrorText

			Main = DTSTaskExecResult_Failure


			Main = DTSTaskExecResult_Success

		end if




End Function

Open in new window

Question by:N R
  • 3

Expert Comment

ID: 22833354
You need to download an FTP object activex to be able to use it.  As far as your syntax goes, it depends on which object the syntax was coded for.  Check out this link:

Expert Comment

ID: 22833411
Here's another link showing how you create the Chilkat ftp object and use it...
LVL 11

Author Comment

by:N R
ID: 22833489
ok I see this in the code I took it from:

set ftp = CreateObject("Chilkat.Ftp2")

That's off my production server, so I assume that the FTP object is loaded on it.  However I'm going to be running this on my dev server so I guess I need to get it for it as well?

Accepted Solution

Dudge669 earned 500 total points
ID: 22833511
Yes, you will need to install the chillkat object on whatever machine your script runs on.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now