File Sharing Violation

Z

Zahid

Hi,

I got this error message:

" there is a file sharing violation. A different process
might be using the file [,,,,] "

What does this mean? How can I solve it?

Thanks in advance.
 
G

Geoff Schwab [MSFT]

This simply means that some process has an exclusive lock on the file
already. Shut down all other processes and if that does not work then try
resetting the device or emulator before running your application. This can
happen when another application is running that has the file open and I
believe it can even occurr when an application failes to properly release
the file before shutting down.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alex Feinman [MVP]

It sounds like an exception coming from SQL CE. If you are using SqlCE,
remember that it allows one connection at a time
 
S

Strider

If this comes from SQLCE, make sure that your database is not allready open
by another process. Check if SQLCE query is running at the background and is
connected to your database.
 
R

Rick Winscot

Zahid,

One thing to remember is that SQL CE is not a multiuser database... and will
only allow a single connection at a time. If you are using .NET take
advantage of the try block... if an exception is caught, you may be able to
step through other windows and kill the process that is using the database.

Rick Winscot
rickly@zyche dot com



Strider said:
If this comes from SQLCE, make sure that your database is not allready open
by another process. Check if SQLCE query is running at the background and is
connected to your database.

Zahid said:
Hi,

I got this error message:

" there is a file sharing violation. A different process
might be using the file [,,,,] "

What does this mean? How can I solve it?

Thanks in advance.
 
G

garfitz

The issue of SQLCE being a single-user database really needs to be
addressed before developing your application as somewhere along the
way a second connection will be fired off or required causing
problems.

One way of getting around this is using a single connection object per
SQLCE database throughout the application.

Each time a piece of SQL is to be run create the command object, point
it to the connection, execute the SQL and then dispose the command
object.

Before executing the SQL, call a function that checks to see if the
connection is already in use. If it is then issue a message to the
user or if required loop until the connection is available.

The connection object does have various states so the following is
possible;

If DBconnection.State = ConnectionState.Executing Then
MessageBox.Show ("The database is busy - try again!")
End If

or

If DBconnection.State = ConnectionState.Closed Or DBconnection.State =
ConnectionState.Broken Then
Try
DBconnection.Close()
Catch ex As SqlCeException
DisplaySQLCEErrors(ex)
End Try
End If

This approach makes the application faster as the connection is always
available - therefore the wait involved in instantiating a new
connection each time a database interaction is required is not needed.
It also allows for multi-threading to be used in the .NETCF.

HTH
Garrett.




Rick Winscot said:
Zahid,

One thing to remember is that SQL CE is not a multiuser database... and will
only allow a single connection at a time. If you are using .NET take
advantage of the try block... if an exception is caught, you may be able to
step through other windows and kill the process that is using the database.

Rick Winscot
rickly@zyche dot com



Strider said:
If this comes from SQLCE, make sure that your database is not allready open
by another process. Check if SQLCE query is running at the background and is
connected to your database.

Zahid said:
Hi,

I got this error message:

" there is a file sharing violation. A different process
might be using the file [,,,,] "

What does this mean? How can I solve it?

Thanks in advance.
 
Joined
Aug 4, 2010
Messages
1
Reaction score
0
Solution to this problem

Hi I realised the issue in my situation was that the shortcut being run to run my app was pointing to its network addess rather than the actual path c:\program files\ etc. The shortcut was pointing to \\computername\c$\etc etc

changed this and it was fine!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top