Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inet1 Annoying me!!!

Status
Not open for further replies.

Jesus4u

Programmer
Feb 15, 2001
110
US
So far this is bugging the heck out of me! I can make a connection that is for sure! And I am following all of the MSDN examples but nothing is transferring over to my local harddrive.
Here is what I have again.
Thanks



code:--------------------------------------------------------------------------------
With Inet1
.Protocol = icFTP
.RemotePort = 21
.URL = "ftp:// .UserName = "2"
.Password = "B"
.Execute , "GET /cats.dbf", "c:\Temp"
.Execute , "CLOSE"
CallMiva = 1
End With
Exit Function
 
Your execute line is no good, try this:
.Execute , "GET /cats.dbf c:\Temp"
The order of URL, username and password is correct, if you change the URL property the username and password wil reset.

 
I added this but

Nothing is working! Still the same. Here is the complete code. I always get a message box saying "Connected
at last" but no .dbf file transfered into the .txt file.

Private Sub Command1_Click()
If CallMiva = 1 Then
MsgBox "Connected at last!"
Else
MsgBox "Not Connected!"
End If
End Sub

Public Function CallMiva()
On Error GoTo errhandler
With Inet1
.Protocol = icFTP
.RemotePort = 21
.URL = "ftp:// .UserName = "2"
.Password = "2wsf"
.Execute , "GET cats.dbf c:\Temp\test.txt"

Do While .StillExecuting
DoEvents
Loop

.Execute , "CLOSE"
Do While .StillExecuting
DoEvents
Loop

End With
CallMiva = 1
Exit Function
errhandler:
MsgBox Err.Description
CallMiva = 0
End Function

Private Sub Inet1_StateChanged(ByVal state As Integer)
Dim vtData As Variant ' Data variable.
Dim intFile As Integer
intFile = FreeFile
Select Case state
' ... Other cases not shown.
Case icResponseCompleted ' 12
' Open a file to write to.
Open "c:\Temp\test.txt" For Binary Access Write As intFile

' Get the first chunk. NOTE: specify a Byte
' array (icByteArray) to retrieve a binary file.
vtData = Inet1.GetChunk(1024, icString)

Do While LenB(vtData) > 0
Put intFile, , vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
Loop
Put intFile, , vtData
Close intFile
End Select


End Sub
 
the StateChanged is used for downlaoding from http sites and there is something wrong allso with the Put intFile, , vtData statement. Just remove the StateChanged code and try it again. If there is no file c:\Temp\test.txt you can check if the path and filename is correct.
 
You can use this code for the StateChanged event van Inet1 to get a directory listing of the ftp url you filled in:
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim strDir As String
Dim strpart
If State = icResponseCompleted Then
strpart = Inet1.GetChunk(1024, icString)
Do While LenB(strpart) > 0
strDir = strDir & strpart
strpart = Inet1.GetChunk(1024, icString)
Loop
strDir = strDir & strpart
MsgBox strDir
End If
End Sub
 
the paths are right. The .dbf file I am looking for just doesn't want to transfer. I have the rights etc..
 
my problem is that the actual file never downloads
 
Try this for statechanged:

Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = icError Then
MsgBox Inet1.ResponseCode & vbCrLf & Inet1.ResponseInfo
End If
End Sub
 
ftp:// is an unknown host, try this when you are connecting/downloading:

With Inet1
.Protocol = icFTP
.RemotePort = 21
.URL = "ftp:// .UserName = "2"
.Password = "2wsf"
.Execute , "cd 1"
.Execute , "GET cats.dbf c:\Temp\test.txt"

Do While .StillExecuting
DoEvents
Loop

.Execute , "CLOSE"
Do While .StillExecuting
DoEvents
Loop

End With
 
thanks I know it's unknown.I can't display the real url here for security sake.
 
Is there a c:\Temp\test.txt or can you download from your ftp site mannually?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top