FTPPutFile error - 32 Sharing violation

May 17, 2013 at 16:36:47
Specs: Windows 7
I had this working then al the sudden I am getting the system error - 32 indicating a Sharing violation. I get good handles for the InternetOpen and InternetConnect Calls. When I used the FTPPutFile call it was working ok unjtil I shutdown and rebooted my computer. Now I get the Error-32 and cannot find a reason. The one thing I have noted is the Wininet.dll is nearly 2.2 Mb vice the 1.6 Mb it is stated and "normal" file sizes at Microsoft web site.

Dim bolTest As Boolean
Dim lHandle, lFlags As Long
Dim sString As String
Dim sURL As String
Dim sCommand As String
Dim sUsername As String
Dim sPassword As String
Dim sDocument As String
Dim sDocumentServer As String
Dim sTemp As String
Dim iPort As Integer
Dim lTest, lTest1, lReturn As Long
Dim sProxyName As String
Dim sProxyBypass As String
Dim lContext As Long
sProxyName = ""
sProxyBypass = ""

With Inet1
lHandle = .hInternet
sURL = "ftp.wd9hnz.com"
sUsername = "Fiftyohms"
sPassword = "Password"
iPort = 21
sDocument = "c:\ThomasMarine\Database\MarineWeb.mdb"
sDocumentServer = "MarineWeb.mdb"
lAccessType = INTERNET_OPEN_TYPE_DIRECT
lFlags = FTP_TRANSFER_TYPE_BINARY
End With

lHandle = InternetOpen(sAgent, lAccessType, sProxyName, sProxyBypass, lFlags)
Debug.Print "InternetOpen returned = " & lHandle
If lHandle = 0 Then
Debug.Print Err.LastDllError
Search.Text = "Unable to open local connection = " & Err.LastDllError & " " & Err.Description
End If
lTest1 = InternetConnect(lHandle, sURL, iPort, sUsername, sPassword, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0&)
Debug.Print "InternetConnect returned = " & lTest1
sTemp = GetLastError()
Debug.Print sTemp
If lTest1 <> 0 Then
sDocumentServer = "/Database/MarineWeb.mdb"
lReturn = FtpPutFile(lTest1, sDocument, sDocumentServer, FTP_TRANSFER_TYPE_UNKNOWN, 0)
sError = GetLastError()
If lReturn = 0 Then
Accessories.Text = "Unable to tranfer Database DLL Error - " & Err.LastDllError & " " & Err.Source
Desc.Text = "Unable to tranfer Database local error - " & Err.Number & " " & Err.Source
Debug.Print "Unable to tranfer Database - " & Err.LastDllError & " " & Err.Source
Else
Search.Text = "Database transferred successfully"
End If
Else
Search.Text = "Unable to connect to FTP server" & Err.LastDllError & " " & Err.Source
End If
InternetCloseHandle lTest1
InternetCloseHandle hOpen

What happened and why am I now getting a file sharing violation from the wininet.dll FTPPUTFILE call ?


See More: FTPPutFile error - 32 Sharing violation

Report •

#1
May 17, 2013 at 18:17:30
Make sure "c:\ThomasMarine\Database\MarineWeb.mdb" is not opened in another program; it probably is. Also make sure you have access to write to "/Database/MarineWeb.mdb". If nothing's using the file and you can manually FTP the file in a client, disable your AV scanner and try again.

How To Ask Questions The Smart Way


Report •

#2
May 17, 2013 at 20:33:19
The program with the access to the database is the program with this code. I use ADODB connectors and WITH Adodb...END WITH to access tables in the database.
As far as the database on the other end of the FTP, I am sending the file to the FTP user and I have access to that..Sending with FilaZilla proves the credentials and access is ok on the server side. This tells me that I believe the error is coming from the local part of the FTP / wininet.dll. Your comment makes some sense except for the fact it worked a couple times but now it doesn't...Something is telling the dll that the database access is consumed by something but the only thing open and running is the EXE in Debug mode via VB 6.0 development. Is there some debug like SPY or something useed in t/sing C-code that would help me find who or what has control control of the database and giving me the Sharing violation on the file ?? based on this any other ideas ??

Report •

#3
May 17, 2013 at 20:57:09
Are you explicitly closing the connections (all of them)? If you don't, ADODB will get around to the cleanup when it wants to, and not when you dispose of the objects.

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
May 17, 2013 at 21:07:00
All of my access are using the
With StaffDB
.Recordset.MoveLast
.Recordset.AddNew
.Recordset.Fields(1).Value = Model.Text
.Recordset.Fields(2).Value = Serial.Text
.Recordset.Fields(3).Value = Desc.Text
.Recordset.Fields(4).Value = Accessories.Text
.Recordset.Fields(5).Value = PicName.Text
.Recordset.Update
.refresh
End With
I am not explicitly opening recordsets using "Set recordset =" construct. I think you might be on to something about the objects and ADO response to Objects. I don't understand why it worked like 8-10 times and now it doesn't..But to answer your question, I am not setting variables and declaring ADO objects...Just the quick way of accessing ADO records through the ADO control, pointing to the database and setting the recordsource using WITH ADODB...END WITH


Report •

#5
May 17, 2013 at 22:12:40
Do you close StaffDB's connection before attempting to FTP the database?

How To Ask Questions The Smart Way


Report •

#6
May 17, 2013 at 23:40:59
sStaffdbConnect = StaffDB.ConnectionString
sNewEquipdbConnect = NewEquip.ConnectionString
sPromotedbConnect = Promote.ConnectionString
sConfigdbConnect = Config.ConnectionString
sMiscEquipdbConnect = MiscEquip.ConnectionString
sUsedEquipdbConnect = UsedEquip.ConnectionString
StaffDB.ConnectionString = ""
NewEquip.ConnectionString = ""
Promote.ConnectionString = ""
Config.ConnectionString = ""
MiscEquip.ConnectionString = ""
UsedEquip.ConnectionString = ""


I used this to close the connect strings for each table in the DB... and disabled Microsoft security essentials and still hav e the sharing violation error 32....
Anythingh else you can think of ??? It just bugs me it works 8-10 then stopped working..The other issue is the blouted wininet.dll from 2.2 Mb from 1.6 Mb...This has to be a DLL issue or something.....


Report •

#7
May 18, 2013 at 00:11:15
I copied the segment out of this program and copied everything I needed to run it in a NEW project and it transfers successfully..I have done it 4 times now....Why when I create a NEW project....It now works..Although I have to admit..I am only transferring the file with no other DB connections established in the new project.....
So if I am using the WITH STAFFDB...END WITH...How do you closed the connection ?? I set the STAFFDB.ConnectionString = ""..If that isn't how to close the ADODB connections then how do you if I am using WITH..End WITH...

Report •

#8
May 18, 2013 at 04:57:37
I don't know the type of STAFFDB, but it should either have a Close() method, or it has a Connection property you can use to call Close(). Also, an object can exist even if you never bother to bind it to a variable.

How To Ask Questions The Smart Way


Report •

#9
May 18, 2013 at 10:23:04
Well, I have a workaround for now...I copied everything I needed for FTP into another program, built it and SHELL () out of my program to this other one that does nothing but FTP. Well, I never instantiated a recordset so I never closed what was never open. I used the ADODB control, set a connection within the control, use the CommandText type in the control. I thought maybe it was because I had FlexGrid control and a dagtagrid control but I disabled those, tried FTP and reenabledf them butr thast wasn't what was causing it. So at this pojnt I have no idea what has the Database within this program but decided to write an FTP only program, shell out to the FTP only....This is working now..Thank you for you help is trying to figure this out. I still don't understand WHY it worked for a while, then it doesn't. But clearly there is a file share violation somewhere. I will need to track this down later with more debug code....I have a work around for now..I will solve this issue....Somehow..Even if it means NOT using With ADODB...END WITH...Instantiating recordsets and CLOSE() when I am done to gain more explicit control over ADO objects...There must be something about using the control the way I am using it that is causing the problem..Thank you again for your comments and help...

Report •

#10
May 18, 2013 at 12:18:29
I used the ADODB control
This control holds the Connection object. It has to, otherwise you would literally be unable to get any data out of the database. If you're creating this on the fly with WITH, stop. You're still consuming the same resources (technically more, since you never clean up the old resources), at the cost of your code clarity, your control over your code, and execution time.

How To Ask Questions The Smart Way


Report •

#11
May 18, 2013 at 14:54:42
I just found out your probably right with the timing...If I run in DEVELOPMENT mode, it works but as soon as I build and use RUNTIME I get the problem....I now know what I need to do...Thank you so much. I believe I got it now..There are timing issues related to Develop/DEsign time and runtime and this was the first time I have run into this..LIGHTS ON..I GET IT !!!

Report •

#12
May 18, 2013 at 16:21:00
. . . This is going to end up with you installing Visual Studio 6.0 on the client's computer, isn't it?

How To Ask Questions The Smart Way


Report •

Ask Question