本文介绍了“无法打开数据库文件" (警告:广泛错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除了IIS上的无法打开数据库文件"外,我似乎无法从SQLite中获取任何东西.我相信SQLite的错误消息像Oracle一样残酷.

I cannot seem to get anything out of SQLite other than "Unable to open the database file" on IIS. I'm convinced SQLite's error messages are as brusque as Oracle's.

  • 在Visual Studio 2010/IIS Express中进行预部署我可以读取和写入文件.
  • 当我尝试使用部署到IIS7.5的同一个VS2010项目读取/写入它时,所有创建",读取"和写入"命令都会失败.
  • 当我通过项目部署数据库文件并尝试读取它时,也会发生同样的情况.
  • 我已向Full control授予了以下用户对App_Data和数据库文件的访问权限:IIS_IUSRSIUSRSDefaultAppPoolEveryone.
  • Pre-deployment in Visual Studio 2010/IIS Express I can both read and write to the file.
  • When I tried to read/write it with the same VS2010 project deployed to IIS7.5, all "create", "read" and "write" commands fail.
  • The same occurs when I deploy the database file through the project and try to read it.
  • I've given Full control access to App_Data and the database file to the following users: IIS_IUSRS, IUSRS, DefaultAppPool, and Everyone.

我看过: SQLite问题无法打开数据库文件" (该问题自动为用户解决了)和许多其他类似的问题,其中大多数通过更改权限,更改为可写目录(App_Data应该是可写的,否?)或将相对路径更改为绝对路径来解决( |DataDirectory|应该解决的.)

I've looked at:SQLite problem "unable to open the database file" (The problem automatically went away for the user) and a number of other similar questions, most of which were solved by changing permissions, changing to a writable directory (App_Data should be writable, no?) or changing a relative path to an absolute one (which |DataDirectory| should resolve to).

<connectionStrings>
    <add name="sqlite" connectionString="Data Source=|DataDirectory|\datatables.sqlite;Version=3;" />
</connectionStrings>

我错过了什么吗?

<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>Unable to open the database file</ExceptionMessage>
<ExceptionType>System.Data.SQLite.SQLiteException</ExceptionType>
<StackTrace>
at System.Data.SQLite.SQLite3.Open(String strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool) at System.Data.SQLite.SQLiteConnection.Open() at AjaxSource.Models.Database.query(String sql, Dictionary`2 parameters) in D:\Tools\Dropbox\Projects\myprojects\AjaxSource\AjaxSource\Models\Database.cs:line 48 at AjaxSource.Models.aaDataModel..ctor() in D:\Tools\Dropbox\Projects\myprojects\AjaxSource\AjaxSource\Models\aaDataModel.cs:line 18 at AjaxSource.Controllers.API.TableDataController.Get() in D:\Tools\Dropbox\Projects\myprojects\AjaxSource\AjaxSource\Controllers\API\TableDataController.cs:line 15 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
</StackTrace>
</Error>

推荐答案

这不是权限问题.问题是我没有检查|DataDirectory|是否确实像应有的那样解析到AppData目录.

It wasn't a permissions problem. The problem is that I didn't check that |DataDirectory| actually resolved to the AppData directory like it's supposed to.

在IIS 7.5服务器上,|DataDirectory|解析为C:\inetpub\wwwroot\AjaxSource\App_Data,但实际的AppData目录是C:\inetpub\wwwroot\AjaxSource\bin\App_Data.

On the IIS 7.5 server, |DataDirectory| resolves to C:\inetpub\wwwroot\AjaxSource\App_Data, but the actual AppData is directory is C:\inetpub\wwwroot\AjaxSource\bin\App_Data.

我使用Fiddler捕获的错误从不提及任何路径,但暗示权限问题.我的其中一个视图使用以下命令显示了已解析的目录:

The errors I caught using Fiddler never mention any paths, but imply a permissions problem. I had one of my views display the resolved directory with:

<h1>@AppDomain.CurrentDomain.GetData("DataDirectory")</h1>

(奇怪的是,此没有记录).

这篇关于“无法打开数据库文件" (警告:广泛错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 18:38