【问题标题】:Unable to work with SQL Server CE 4.0无法使用 SQL Server CE 4.0
【发布时间】:2013-10-04 05:24:56
【问题描述】:

我尝试通过我的简单控制台应用程序使用 SQL Server CE 4.0 数据库,但它在我的一台机器上无法运行。

操作系统:Windows Server 2003 Enterprise x64 Edition with Service Pack 2

我还安装了 Microsoft SQL Server Compact 4.0 并使用了它的 dll (System.Data.SqlServerCe.dll),但每次都出现以下错误

无法加载 SQL Server C 的本机组件 版本 8080 的 ADO.NET 提供程序。安装正确的 行为。有关详细信息,请参阅知识库文章 974247。

这是我的代码

 try
        {
            Console.WriteLine("Started");

             var sqlConnectionString = "Data Source=c:\\tde\\22\\22.tde;password='sanjayraj';mode=Read Write;max database size=4091;temp file max size=4091";
            _connection = new SqlCeConnection(sqlConnectionString);
            _connection.Open();

            var sqlStatement = "SELECT * FROM InfoStores WHERE Location = 'Source'";

            IDbCommand newCommand = new SqlCeCommand
            {
                CommandText = sqlStatement,
                Connection = _connection,
                CommandType = CommandType.Text
            };

            using (IDataReader reader = newCommand.ExecuteReader())
            {
                while (reader.Read())
                {
                    Console.WriteLine(reader[0].ToString());
                }

            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error Occured");
            Console.WriteLine(ex.Message);
            Console.ReadKey();
        }

        Console.WriteLine("Finished");
        Console.ReadKey();

【问题讨论】:

    标签: c# sql-server-ce-4


    【解决方案1】:

    您引用了错误版本的 System.data.SqlServerCe.dll,请使用 C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Desktop 文件夹中的那个

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-04
      • 2011-09-02
      • 2012-03-01
      • 2011-07-12
      • 1970-01-01
      • 1970-01-01
      • 2017-07-11
      • 1970-01-01
      相关资源
      最近更新 更多