0
我尝试使用简单的控制台应用程序与SQL Server CE 4.0数据库一起工作,但它不适用于我的一台计算机。无法使用SQL Server CE 4.0
操作系统:Windows Server 2003 x64企业版与Service Pack 2
我还安装了微软的SQL Server Compact 4.0和使用它的DLL(System.Data.SqlServerCe.dll
),但每一次我得到了以下错误
无法加载SQL Server的本地组件C 版本8080的ADO.NET提供程序。安装correc 操作。有关更多详细信息,请参阅知识库文章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();