Unable to open database file

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
bgosdin
Posts: 3
Joined: Tue 16 Apr 2013 20:10

Unable to open database file

Post by bgosdin » Tue 16 Apr 2013 20:23

The bug related to "Unable to open database file" exception when opening several connections in the LinqConnect for Metro edition was not fixed in 4.1.184 07-Feb-13 release. This code runs the first two times but after that it will give the "Unable to open database file". I am using direct calls because this is much faster than the linq to sql method when running in a transaction. I can load 100000 this way in minutes.

using (SQLiteConnection sqliteconnection = new SQLiteConnection("Data Source = database.db3; Version=3"))
{

sqliteconnection.Error += new SQLiteConnection.SQLiteErrorEventHandler(SQLiteError); ;
sqliteconnection.Open();

using (SQLiteTransaction sqlitetransaction = sqliteconnection.BeginTransaction())
{
SQLiteCommand command = sqliteconnection.CreateCommand();

try
{
command.CommandText = AttributeHelper.CreateInsertWithParameter<T1>(dc, ref command, add_items[0]);
command.Prepare();

foreach (var add_item in add_items)
{
AttributeHelper.SetParameters<T1>(dc, ref command, add_item);

command.ExecuteNonQuery();
sqlitetransaction.Commit();
}
catch
{
if (sqlitetransaction != null)
{
sqlitetransaction.Rollback();
}
}

if (sqliteconnection.State != ConnectionState.Closed)
{
sqliteconnection.Close();

if (sqliteconnection != null)
{
sqliteconnection.Dispose();
}

if (sqlitetransaction != null)
{
sqlitetransaction.Dispose();
}

if (command != null)
{
command.Dispose();
}
}
}
}
}
}

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unable to open database file

Post by MariiaI » Wed 17 Apr 2013 12:20

These issues are not the same. The issue, you have reported, is related to working with transactions and configuration of the 'JournalMode' parameter of the connection string. We are working on this issue now and we will inform you about the results as soon as possible.
As a temporary workaround, please set the 'JournalMode' parameter of your connection string to 'Off'.

We also recommend you to use your connection string in the ways which are demonstrated in the "Database Deployment and Connection String Format" section at http://blogs.devart.com/dotconnect/linq ... guide.html
For example:

Code: Select all

using (SQLiteConnection sqliteconnection = new SQLiteConnection("Data Source = ms-appdata:///local/database.db"))
{...}
Please tell us if this helps.

bgosdin
Posts: 3
Joined: Tue 16 Apr 2013 20:10

Re: Unable to open database file

Post by bgosdin » Wed 17 Apr 2013 12:46

Thanks for the response, tried the solution given. Changed code to the following.

var dbPath = "ms-appdata:///local/supersuite.db3";

connectionString = string.Format("Data Source = {0}; Version= 3; Journal Mode=Off;", dbPath);

I still receive error "unable to open file" on third attempt.

bgosdin
Posts: 3
Joined: Tue 16 Apr 2013 20:10

Re: Unable to open database file

Post by bgosdin » Wed 17 Apr 2013 17:59

A fix for issue "Unable to open file" for metro can be found here

http://briandunnington.blogspot.com/201 ... t-bug.html

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unable to open database file

Post by MariiaI » Thu 18 Apr 2013 10:28

Thank you for your involvement. We will investigate the issue with the "Unable to open database file" exception and inform you about the results as soon as any are available.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Unable to open database file

Post by MariiaI » Mon 10 Jun 2013 07:09

The bug related to the "Unable to open database file" with different variants of JournalMode in Metro style applications is fixed.
The latest build of LinqConect for Metro can be downloaded from http://www.devart.com/linqconnect/download.html (trial version) or from Registered Users' Area (for users with active subscription only).
For more information, please refer to http://forums.devart.com/viewtopic.php?f=31&t=27137

Post Reply