Solved

Visual Basic error 32

Posted on 2004-09-08
5
920 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
ID: 12007110
What is the exact error message?
How are you connecting to the server?
0
 
LVL 6

Author Comment

by:campbelc
ID: 12007991
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
ID: 12008542
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
ID: 12008566
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
ID: 12009073
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

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

Title # Comments Views Activity
A macro to Count the number of rows across all worksheets 3 78
Windows 10 start screen issues 9 51
MS Date Picker 64 bit 32 bit issue 12 49
VB6 - Convert HH:MM into Decimal 8 51
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

919 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