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.
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.
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>
Have I missed anything?
<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>
I had a problem opening Sqlite database in IIS
(0x80004005): unable to open database file unable to open database
file
what helped me to solve the problem is changing the "Identity" of the application pool to "LocalSystem"
Application Pools -> DefaultAppPool (or another pool you are working with) -> Advanced Settings -> Identity -> LocalSystem
Hopefully it will save someone time...
We used to encounter this problem on the machines of our customers most often, and I have made a lot of investigation upon it and finally we've solved it.
First of all, you need to make sure that your application has read/write access to the database file as well as the folder containing the database file. In most situations, the check will fix the issue; but we are not among those fortunate ones.
In our case, where the application makes very highly concurrent access to the database, it's most probably related to the journal mode of the database, which usually is DELETE by default. That is to say, the rollback journal will be deleted once the corresponding transaction is committed or rolled back. On **nix systems, it's no error; but on Windows systems, it's another story, as can be seen below. On Windows systems, the problem could take place in the following scenario:
A journal file (say A) is created by a SQLite thread.
Another thread P tries to open A.
SQLite has finished its transaction and so deletes the journal file A.
But now thread P has handle for A, so SQLite enters the “Delete Pending” state.
SQLite starts another transaction and has to recreate the journal file (with the same name).
Windows reports ERROR_DELETE_PENDING error (see here for more information: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/09/6001644.aspx)
SQLite report SQLITE_CANTOPEN error (that is, "Unable to open the database file").
P finally releases the file handle and A is deleted.
One solution is to use PERSIST or TRUNCATE journal mode instead of DELETE. See here for more details: http://www.sqlite.org/pragma.html#pragma_journal_mode
In this way, the rollback journal (.-journal) is not deleted at all, and thus we can get rid of the problem you said. I hope this helps.
Well I don't know if this will answer your question, but in my case I had a dummy error which is that I gave a wrong relatif URL to the database file when I copied my code from a commandline projet to the mvc one. Hope someone will find this useful.
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.
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.
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>
(Oddly, this isn't documented).
Related
I have a problem in terms on connecting my DbLogSystem.mdb to my program.
1) When I try to insert/update a record using the program, it will proceed and perform successfully,
2) When I try to reset/delete all the records using MS Access it will proceed,
But when I Run my program the data/records are still existing.
What is the possible error?
Thanks in advance.
Below is the connection string that might cause the problem:
mydir := GetCurrentDir;
ADOConnection_get_data.ConnectionString:= 'Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=puzzle33;Data Source='+ mydir +'\DbLogSystem.mdb;Persist Security Info=False';
or is there any method to link my .Exe program to my Database with the same path folder?
I believe you could just use a relative path to always link your .exe program with the database on the same folder
ADOConnection_get_data.ConnectionString:= 'Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=puzzle33;Data Source=.\DbLogSystem.mdb;Persist Security Info=False'
As Zam says, check that you aren't alternating with two different database at the Release and Debug folders.
Also, are you sure you are commiting your changes ?. You may be using CommitUpdates (so your changes never really arrive to the database), or you may have an active transaction that you never commit (so it's rollbacked when you exit your application).
I've come across an unbelievably stupid situation with my ASP.NET MVC application hosted in IIS 7.5. Here's the case:
I publish the application to the server and test it. It works just fine
I change anything in the web.config file and then undo the change. So it's in its original state
I test the application again but this time I get
Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Data.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. error.
Please note this: I just open the web.config file and edit and then immediately undo that edit. It doesn't matter in which line of which section I make edit. (After all, aren't configuration files there to not have to touch the code?)
Now comes more interesting part.
I copy and paste the latest published files to the application folder
test the application: Still get the same error
I republish the application and copy/paste to the folder, EXCEPT FOR THE WEB.CONFIG FILE. So I don't even touch the "damaged" config file.
Test it, voila, it works.
I just don't get it. Do you have any clue about this issue?
The problem was caused by a third party tool called EntityFramework Profiler with which I traced SQL commands issued by Entity Framework. After removing it from the application, the problem disappeared.
I have code using the SysOperationFrameworkService, and after a model-deploy or some other set of circumstances, many users get Function SysOperationDataContractInfo::newParameterInfo has been incorrectly called..
It's unable to be resolved with full-compile, sync, full CIL, deleting XPPIL files, deleting AUC/KTI, usage data, security (they're admin), refreshing caches (server &client), etc. and I have a ticket open with Microsoft and they're struggling.
I've narrowed the issue down to when the service group AxClient located in the AOT at \Service Groups\AxClient WSDL files get deployed to C:\Users\[User]\AppData\Local. Either those files existing there, or something happening when those files get deployed is needed.
Any idea how/what causes these files (AxClient.wsdl, etc) to be created? With a user who happens to be "working", I can close the client, delete all the files, open the client, and no files will exist...then I perform a SysOp process and those files get created during that process. With the non-working user, with same security on the same machine does it, the files don't get created.
I have found that the
"Function SysOperationDataContractInfo::newParameterInfo has been incorrectly called" has been throwed because of a possible bug in the kernel when calling the "dictMethod = new DictMethod(UtilElementType::ClassInstanceMethod, dictClass.id(), methodName);" in the SysOperationServiceController.getServiceOperation() method. In my case the new DictMethod was sometimes unable to get the method parameter from a superclass, causing the _parentMethodParameterName check fail in the SysOperationDataContractInfo.newParameterInfo.
So, I solved the issue just by doing an override of the super method where the parameter could not be retrieved and then just calling super(_parameter), then everything went well.
Have you tried axclicfg.exe -> connections -> refresh
I am having a very frustrating problem with my current project. It is continually losing the connection string binding for Entity models.
I have multiple models for different databases in separate areas and was having no problems. Suddenly now whenever I try to update from the database I get the connection string setup prompt. I select for it to add it to the Web.config with the password but it doesn't ever pick it up there again. They all are still in the web config but it just doesn't see them.
If I remove all the connection strings from the config file it will write the new one there. Then when I try to set up a Stored procedure/Function Import, I still get the statement in the lower box:
No database connection has been configured for this model.
I have tried rebuilding the project and creating the models again from scratch and that works for a while. When I try and bring the project in under Perforce source control, it winds up getting re-corrupted & the connection string goes away. It affects all of my models too.
I am also using EF 4.x DbContext Generator to create context files. They work fine. I am also able to run the application and it connects to the database just fine and returns data. No issues there. I am just unable to update Entity Complex types from the DB or import any more stored procedures.
An even weirder occurrence was that I opened a broken project from a different directory then opened an uncorrupted copy it instantly became broken also. Contagious!
Any thoughts on where to look into to see why this is happening? Has anyone else had this issue?
I seem to have found where the issue is coming from.
I seem to have a bad value somewhere in my web.config which causes the issue. Here is the work around I found did the trick and showed it's the config:
When the binding breaks, I closed the project then swapped out the web.config with one from a good build which was missing a couple keys but worked well enough to bind.
I reopen the the solution and the "No database connection..." error goes away.
Then while the solution is still open I re-swap the web.config back in and it still works.
This is far from optimal but I can work until I figure out the bad value via doing some compares.
I will comment on this again once I determine the exact issue.
Hi i have a working app that uses an attached mdf file with the following connect string :
<add name="SqlDataContext" connectionString="Data Source=.\SQLEXPRESS;Integrated Security=true;User Instance=true;AttachDBFilename=|DataDirectory|\WPCloudApp26.mdf;Initial Catalog=WPCloudApp26;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
I am using a Windows phone cloud application template and i have azure storage emulator running on my pc
everything works fine, until i do the following steps for the first time:
i want to view the database so i double click the app_data/WPCloudApp26.mdf file through visual studio when the app is not running. when i double click it, the db opens up under data connections in the server explorer pane and i can see the database and all the tables. so far everything good
I am done viewing the db, so i close the connection by right clicking --> close connection.
i want to run the app again, and when i run it all hell breaks loose. i get the following error message:
One or more files do not match the primary file of the database. If
you are attempting to attach a database, retry the operation with the
correct files. If this is an existing database, the file may be
corrupted and should be restored from a backup.\r\nCannot open
database \"WPCloudApp26\" requested by the login. The login
failed.\r\nLogin failed for user 'NT AUTHORITY\NETWORK
SERVICE'.\r\nLog file 'C:\Users\michael\Documents\Visual Studio
2010\Projects\WPCloudApp26\WPCloudApp26\WPCloudApp26.Web\App_Data\WPCloudApp26.ldf'
does not match the primary file. It may be from a different database
or the log may have been rebuilt previously.
the exception is thrown on the method var firstItem = context.SqlSampleData.FirstOrDefault();
Thats it, no matter what i do, i can't run the app again. this is driving me crazy since the only thing to help is to create a new solution with a different name (thats why i got to number 26)
What is going on ? why is this happening only after the first time i try to view the database in visual studio ?
Edit
i have noticed that changing the initial catalog and mdf file in the connection string solves the problem. So where are the remnants of the db name are saved ? how can i clean up old leftovers ?
You shouldn't try to open a .MDF file that is attached to SQL Server Express. It will probably break the consistency between the .MDF and the log file.
Connect to the SQL Server Express server using the Server Explorer, or SQL Server Management Studio. (There's a free version of it for Express as well)
If you really want to open the .MDF in Visual Studio, then detach the DB from SQL Server Express first.