简体   繁体   English

SQL Server Compact 4.0不在x86上运行

[英]SQL Server Compact 4.0 not running on x86

  • C# project / Visual Studio 2015 C#项目/ Visual Studio 2015
  • Build PC Windows 7 Pro 64 bit 构建PC Windows 7 Pro 64位
  • Client PC Windows 7 32 bit (x86) 客户端PC Windows 7 32位(x86)
  • SQL Server Compact 4.0 / .net Framework 4.5 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. 应用程序按构建PC上的设计工作。

Receiving the following error when the application attempts to connect to the database on the Client PC: 当应用程序尝试连接到客户端PC上的数据库时,收到以下错误:

System.Data.SqlServerCe.SqlCeException (x800004005): The database file may be corrupted. System.Data.SqlServerCe.SqlCeException(x800004005):数据库文件可能已损坏。 Run the repair utility to check the database file. 运行修复实用程序以检查数据库文件。

I used to CompactView to repair the database and received the following message: 我曾经使用CompactView修复数据库,并收到以下消息:

System.Data.SqlServerCe.SqlCeException (x800004005): The database encryption mode is invalid.. System.Data.SqlServerCe.SqlCeException(x800004005):数据库加密模式无效。

I added the sqlce...40.dll files to the app folder and that did not work either 我将sqlce...40.dll文件添加到app文件夹中,但该方法也不起作用

Also tried turning off prefer 32bit, tried x86 instead of Any CPU 还尝试关闭首选32位,尝试使用x86代替任何CPU

Help!! 救命!!

Too many hours, too much stress. 太多时间,压力太大。 I had the SQLite '.db'extension instead of the SQLCompact extension '.sdf.' 我有SQLite'.db'扩展名而不是SQLCompact扩展名'.sdf'。

Major embarrassment. 严重的尴尬。 Thank you ErikEJ for asking about the connection string. 感谢ErikEJ询问连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM