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 2000 Forums
 SQL Server Development (2000)
 Creating CmdExec Job To Run VB.Net App

Author  Topic 

ana
Starting Member

2 Posts

Posted - 2005-03-22 : 18:58:14
I have this VB.Net application that transfers a text file to another server thru FTP. I got this FTP class from MSDN, and have used the class for several times without problems when run normally on my PC or other servers.

But when I put the vb.net app to an SQL Job, it does the FTP but continues to have the status of "Executing Job Step 1...". To test if the Execute Process task is succesfull, I put an SQL Execute task (Insert date to an sql table) when the process task suceeded, but no date was inserted. I think the process just stops or hang after the FTP.

How will I know if the vb.net app hang? Oh, I also test it in the DTS package and all runs smoothly till the end. My problem is the job step. Does anyone experience this same problem? Your help would do me a lot.

Ana

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-03-22 : 19:05:52
Is your VB.Net app written as a console app? Or does it have a GUI interface? Anything run from a SQL job or DTS package should NOT have a user interface as it could hang the job waiting for input.

BTW, Windows comes with an FTP command-line utility that works very well in SQL Server jobs.
Go to Top of Page

ana
Starting Member

2 Posts

Posted - 2005-03-22 : 19:21:30
My app does not require user interface. Below is a sample. I need to put this on schedule very 6pm. BTW, do have any sample that does the Windows FTP command-line in SQL jobs? I can try that.

Public Class Form1
Inherits System.Windows.Forms.Form

Dim ECN As New classILS.ECN
Dim ILS As New classILS.ILS
Dim FTP As New classFTP.clsFTP 'this is the FTP class I put in my vb reference
Dim vSQL, destination As String
Dim vSDA As SqlDataAdapter
Dim vDS As New DataSet
Dim vDBcomm As SqlCommand
Dim vDBreader As SqlDataReader

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
'get data source
vSDA = New SqlDataAdapter("sp_ForwardECN", ECN.connWorkflow)
vSDA.Fill(vDS)
'create text file
destination = "E:\filez\ILS\Textfile\Enrollment.txt"
'routine that create the text file in class ILS
ILS.createTextFile(vDS.Tables(0), destination, "Create")

'ftp text file to FTPserver
FTP.RemoteHostFTPServer = "123.45.67.89"
FTP.RemoteUser = "blah"
FTP.RemotePassword = "blahblah"
FTP.Login()
FTP.UploadFile(Path.GetFullPath("Textfile\Enrollment.txt"))
FTP.CloseConnection()

Me.Close() 'auto close the form after FTP
End Sub
End Class

Ana
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-03-22 : 19:34:20
Use Notepad to create a text file named "ftp.txt" and copy the following into it:

open 123.45.67.89
user blah blahblah
put E:\filez\ILS\Textfile\Enrollment.txt
quit


Change the IP address after the "open" command and the user name and password after the "user" command to match your actual settings.

Then create a regular SQL Server job with a single Operating System step, containing the following:

ftp -v -i -n -s:ftp.txt

That command will run ftp and use the commands listed in the ftp.txt file to connect and upload the file. You can find out more about the ftp commands in the Windows help file, or post here.
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2005-03-22 : 19:34:42
Inherits System.Windows.Forms.Form

^^^ There's your problem. Like Rob said, this needs to be a Console Application, and not a WinForms application.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-03-22 : 19:36:12
Yeah, that's how much .Net I do, I didn't even see that. Thanks Michael.

Anyway, as you can see, the command-line utility is pretty simple to use.
Go to Top of Page
   

- Advertisement -