Solved

Visual Basic error 32

Posted on 2004-09-08
5
918 Views
Last Modified: 2013-11-25
Receiving this error while trying to put file on our unix server. Seems to connect just fine and does a directory change, just errors while trying to put the file.

Any help would be appriciated!
0
Comment
Question by:campbelc
  • 2
  • 2
5 Comments
 
LVL 32

Expert Comment

by:Erick37
Comment Utility
What is the exact error message?
How are you connecting to the server?
0
 
LVL 6

Author Comment

by:campbelc
Comment Utility
The returned error code is 32. No error text is returned.

The InternetOpen works just fine and returns 13369348.
The InternetConnect works just fine and returns 13369352.
The FtpSetCurrentDirectory works just fine and returns true.
I can easily test any of the above simply by providing invalid values, which as expected result in failure return codes.

The FtpPutFile fails. It returns false, and the last error code is 32 as noted above. No text is returned.

I have multiple examples of VB source code. All work just dandy. All transfer the test file just fine. I have used code from each of these examples in my target program, and the result is always as noted above. I've compared variable contents value-for-value between the working and target programs, variable types and everything else I can think of. Obviously something is different between several working source codes and my target program, but I'm damned if I can find a difference.

Any suggestions would be appreciated. Thanks!
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 150 total points
Comment Utility
OK,

Assuming that the error number 32 is derived from calling err.lastDLLerror immediately after the call to FtpPutFile, you can get the text of the error with this function:

Private Declare Function FormatMessage Lib "kernel32" _
      Alias "FormatMessageA" (ByVal dwFlags As Long, _
      lpSource As Any, ByVal dwMessageId As Long, _
      ByVal dwLanguageId As Long, ByVal lpBuffer As String, _
      ByVal nSize As Long, Arguments As Long) As Long
   
Private Const FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000

'----------------------------------------------------------------------------
Private Function ApiErrorText(ByVal ErrNum As Long) As String
      Dim msg As String
      Dim nRet As Long
   
      msg = Space$(1024)
      nRet = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, _
                           ErrNum, 0&, msg, Len(msg), ByVal 0&)
      If nRet Then
         ApiErrorText = Left$(msg, nRet)
      Else
         ApiErrorText = "Error (" & ErrNum & ") not defined."
      End If
End Function
'----------------------------------------------------------------------------

Plugging in the number 32 results in the text message:
"The process cannot access the file because it is being used by another process."

That's all I have so far... still searching for an answer.
0
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
Have you tried this program

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3BQ175179


May be there is security problem have you tried to connect via just


ftp


run from command prompt?
0
 
LVL 6

Author Comment

by:campbelc
Comment Utility
oh. ouch.

That's it, absolutely. The target program hadn't closed the file. Program worked immediately when I explicitly closed the file.

That's why the other sources worked fine, because the program I was developing wasn't running and holding the file open.

Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

13 Experts available now in Live!

Get 1:1 Help Now