views:

261

answers:

1

Are there any issues with using SQLite and SubSonic in a windows service. (have only tested on Vista)

edit:

I have a windows application and windiows service that needs to run on the same database. The windows app works fine (after adjusting the connection string and compiling the SubSonic Core with the updates mentioned here http://www.integratedwebsystems.com/2009/11/playing-with-sqlite-subsonic3-and-repository-mode ). I get a message from the service indicating it's unable to open the database. I have both executables in the same place with the database in an App_data folder. The service is running under it's default user as installed. The service in this instance is running on its own.

I am taking advantage of "RunMigrations" to set up the database. The Application and Service first checks the version of the database, then runs various List funtions to ensure the database tables are created.

The first bit of code (part of a very basic object/DAL layer) looks like this:

public static DatabaseInfo Get()
        {
            var repository = Made4Print.SQLite.Repository;

            var databaseInfos = (from database in repository.All<DatabaseInfo>()
                                 select database).Take(1);

            if (databaseInfos.Count() > 0)
            {
                var databaseInfo = databaseInfos.First();
                databaseInfo._IsNew = false;
                databaseInfo._CurrentID = databaseInfo.ID;
                return databaseInfo;
            }

            var newDatabaseInfo = new DatabaseInfo();
            newDatabaseInfo = newDatabaseInfo.Save();
            return newDatabaseInfo;
        }

Method to get provider look like this:

public static IDataProvider GetProvider()
        {
            string connectionString = @"Data Source=App_Data\Database.db; Version=3; New=True; Pooling=True;Max Pool Size=20; Journal Mode=Off";
            return ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
        }
A: 

One of the things you need to take care with services is checking which account it runs under. So before firing up your service, right-click it and check the property pages to see which account is being used. Needless to say, your database needs to agree to let the chosen account interact with it.

Dmitri Nesteruk
The Service is running under the "Local System" account. Does the local system not have access to the App_Data folder?"your database needs to agree to let the chosen account interact with it"; Do you mean file access permissions in windows?
Mark Redman
Running the service under my login account (admin user on vista) has the same effect.
Mark Redman