0
  • C# project / Visual Studio 2015
  • Build PC Windows 7 Pro 64 bit
  • Client PC Windows 7 32 bit (x86)
  • SQL Server Compact 4.0 / .net Framework 4.5

Code:

/// <summary>
/// Connects this instance.
/// </summary>
/// <returns></returns>
public bool Connect()
{
            bool connected = true;
            string cs =  Properties.Settings.Default.ConnectionString;

            try
            {
                cnn = new SqlCeConnection(cs);
                cnn.Open();
                connected = true;
            }
            catch(System.ArgumentException ae)
            {
                connected = false;

                if(ae.HResult == -2146233067)
                {
                    MessageBox.Show("Please check database location setting", "Arkema Database Connection Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                return connected;
            }
            catch(SqlCeException ex)
            {
                connected = false;
                MessageBox.Show(ex.ToString(), "Arkema Database Connection Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return connected;
            }

            return connected;
}

Database file is NOT corrupt and NOT encrypted. Application works as designed on the build PC.

Receiving the following error when the application attempts to connect to the database on the Client PC:

System.Data.SqlServerCe.SqlCeException (x800004005): The database file may be corrupted. Run the repair utility to check the database file.

I used to CompactView to repair the database and received the following message:

System.Data.SqlServerCe.SqlCeException (x800004005): The database encryption mode is invalid..

I added the sqlce...40.dll files to the app folder and that did not work either

Also tried turning off prefer 32bit, tried x86 instead of Any CPU

Help!!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ConcordCA
  • 23
  • 1
  • 1
  • 6
  • Connection string, please! What happens when you open the file using the SQL Server Compact Tolbox on the client pc? – ErikEJ Nov 21 '15 at 08:18
  • Connection string is the usual "Datasource = C:\SomeFolder\SomeDatabase.sdf" SQL Server Compact Toolbox is a Visual Studio add-in. This would require Visual Studio on the client PC. Using CompactView, I can see the data. – ConcordCA Nov 21 '15 at 18:48

1 Answers1

0

Too many hours, too much stress. I had the SQLite '.db'extension instead of the SQLCompact extension '.sdf.'

Major embarrassment. Thank you ErikEJ for asking about the connection string.

ConcordCA
  • 23
  • 1
  • 1
  • 6