尝试打开连接时出现错误。我的 DB.sdf 文件在我的应用程序文件夹中
我在这里存储了 db.sdf
{
string ConnectionString= new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + @"\APP_DATA\DB.sdf";
public int ExecuteNonQuery(string query){
int res = -1;
try
{
using (SqlCeConnection conn = new SqlCeConnection(ConnectionString))
{
SqlCeCommand command = new SqlCeCommand(query, conn);
command.CommandType = CommandType.Text;
conn.Open();
res = command.ExecuteNonQuery();
}
}
catch (Exception e)
{
new Logs().TraceProcessError(e.Message);
}
return res;
}
}
错误:
您正在尝试访问旧版本的 SQL Server Compact Edition 数据库。如果这是 SQL Server CE 1.0 或 2.0 数据库,请运行 upgrade.exe。如果这是 SQL Server Compact Edition 3.0 或更高版本的数据库,请运行 Compact / Repair。[ Db 版本 = 3505053,请求版本 = 3004180,文件名 = D:\DB.sdf ]"
我正在使用 SQL Server Compact 3.5.、VS2010、SQLServer 2008R2。
请帮忙。谢谢。