Sharing Violation ofsdf file in PocketPC

  • Hi,

    I’m working on an application written in C# in Compact Framework 2.0 for a Pocket PC. It is required that the application connects to the SQL CE database frequently. The sdf file is present in the PocketPC. Now I’m facing a problem now and then when the code tries to connect with the sdf file.

    The code works fine for some time and then it suddenly starts throwing "There is a file sharing violation. A different process might be using the file."

    I am disposing and closing the connection after each operation.

    Please find the function code below which is being used for any database operation.

    SqlCeConnection sqlCon = null;

    try

    {

    sqlCon = ConnectionFactory.getInstance().getPrimDsConnection();

    sqlCon.Open();

    readCmd = sqlCon.CreateCommand();

    this.prepareStmtManyRows();

    dataReader = this.readCmd.ExecuteReader();

    IList result = this.populateManyRows();

    return result;

    }

    catch (SqlCeException sqlEx)

    {

    StringBuilder builder = new StringBuilder(

    @"SqlCe Error in BaseReader.executeList() - ").Append(

    sqlEx.Message).Append(':').Append(sqlEx.NativeError);

    Log.getInstance().log(builder.ToString());

    throw new DataAccessException(sqlEx);

    }

    finally

    {

    try

    {

    if( null != dataReader && ( !dataReader.IsClosed ))

    {

    dataReader.Close();

    dataReader.Dispose();

    }

    if( null != readCmd) readCmd.Dispose();

    if( null != sqlCon) sqlCon.Close();

    }

    catch (System.Exception ex)

    {

    }

    }

    I have also made sure that Query Analyzer is not running on my PDA.

    Any help will be appreciated.

    Many Thanks,

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply