Win XP 上 SQL Server CE 的权限被拒绝 [英] Permission denied for SQL Server CE on Win XP

查看:26
本文介绍了Win XP 上 SQL Server CE 的权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我连接到 .sdf 文件时,我收到 Permission denied" 异常.

I am getting a "Permission denied" exception when I connect to a .sdf file.

我正在使用此连接字符串.

I am using this connection string.

connection string="Data Source=|DataDirectory|\DB.sdf;Password='something';Mode = Read Only;Temp Path= Environment.GetFolderPath(Environment.SpecialFolder.Templates);Persist Security Info=True"" providerName="System.Data.EntityClient" />

这在 Win 7 上工作正常,但是当我在 Win XP 上运行我的应用程序时它返回

This is work fine on Win 7 but when I run my app on Win XP it returns

权限被拒绝

例外

我尝试了临时文件的不同地址,但仍然失败.所有这些选项都是正确的

I tried different address for temp file but it still failed.all of this options are true

  1. 数据库文件的路径存在于 xp 机器上
  2. 我有权在给定的文件中创建一个临时文件目录
  3. 我提供了正确的密码.

这个问题只是在数据库连接字符串设置为只读时发生.我找到了一些解决方案,但我不能使用它们:

This problem happens just when data base connection string set to read only.i find some solution but i can't use them:

解决方案 1:

这里是独家新闻.当我们将 SDF 文件从 XP 移动到 Vista 时,由于 NLS 版本的更改,我们尝试在读写模式重写索引(如果存在).这只发生在从XP 到Vista 移动的第一次打开.所以一个简单的工作对你来说就是暂时把文件改成读写模式在 Vista 上打开它并将其恢复为只读.

Here is the scoop on this. When we move a SDF file from XP to Vista, because of a change in the NLS Version we attempt to open the file in read-write mode to rewrite the indexes if any exist. This happens only on the first open on the move from XP to Vista. So a simple work around for you is to temporarily change the file to read-write mode open it on Vista and revert it back to read-only.

我无法使用此解决方案,因为我的应用程序从 DVD 运行.

I can't use this solution because my application run from DVD.

解决方案 2:

有 3 个 sdf 文件,一个用于 XP/Server 2003,一个用于 Vista/Server2008/Win7和win 8一个

having 3 sdf files, one for XP/Server 2003 and one for Vista/Server 2008/Win7 and one for win 8

这也很糟糕,因为我在应用程序 DVD 上没有可用空间来执行此操作.

This is also awful,because i don't have free space on application DVD to do this.

任何人都有解决这个问题的好主意.

any one have a good idea to solve this problem.

推荐答案

您需要在 DVD 上拥有 2 份数据库文件副本,一份用于 XP/Server 2003,一份用于 Vista 及更高版本.或者在应用程序首次启动时将数据库复制到可写位置.同样的问题适用于 SQL Server Compact 4.0

You will need to either have 2 copies of the database file on the DVD, one for XP/Server 2003, and one for Vista and later. Or copy the database to a writable location when the app is first launched. Same issue applies to SQL Server Compact 4.0

这篇关于Win XP 上 SQL Server CE 的权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆