Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4320486
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:38:23+00:00 2026-05-21T08:38:23+00:00

I’m trying to get Community.Csharp working with Windows Phone, I’ve tried using both the

  • 0

I’m trying to get Community.Csharp working with Windows Phone, I’ve tried using both the version from http://wp7sqlite.codeplex.com/ and compiling the main trunk with the WINDOWS_PHONE flag, but when I run the application on the phone I get an error when trying to execute any queries (but not when opening the database; only on queries): “Unable to open database file”

_conn = new SqliteConnection("Version=3,uri=file:recipes.sqlite");
_conn.Open();
cmd.CommandText = "SELECT * FROM recipes";
SqliteDataReader reader = cmd.ExecuteReader();

Interestingly though, I’m using the following to check for the existence of a table and no exceptions are thrown:

cmd.CommandText = "SELECT * FROM sqlite_master WHERE name='" + tableName + "'";
SqliteDataReader rdr = cmd.ExecuteReader();
exists = rdr.Read();
rdr.Close();

I have a Windows app which uses SQLite, so if I could use SQLite as opposed to Sterling DB or something else, that would save huge amounts of time. The problem I’m having currently is that once I open the database and close it, I cannot re-open it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T08:38:24+00:00Added an answer on May 21, 2026 at 8:38 am

    I am using the same library for our company’s application and as far as I know, also documented at http://wp7sqlite.codeplex.com (under Some Recommendations ), if you close the connection you’ll need to recreate it again.

    == ADDITIONAL COMMENTS ==

    I’ve tracked down the cause of the error, created a fix and am testing it in our application. Briefly, in order to port the Community.CSharpSqlite library to WP7, the author wrote a FileStream wrapper around WP7 IsolatedStorageFileStream. When a db is opened, the db file stream is opened and read and closed by CSharpSqlite. But a handle to this stream is also stored in a Dictionary mapping the file path to stream. When a db is opened for a second time, the handle to the stream is retrieved but since it’s closed (I’m assuming, haven’t verified yet) the db fails to open.

    I will attempt to get my changes deployed to the wp7sqlite.codeplex.com project, but in the meantime if you have the source code make the following changes to Community.CsharpSqlite.FileStream

    change from

        public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int unused)
        {
            IsolatedStorageFileStream handler = null;
            if (FileStream.HandleTracker.TryGetValue(path, out handler))
            {
                _internal = handler;
            }
            else
            {
                if (mode == FileMode.Create || mode == FileMode.CreateNew)
                {
                    _internal = IsolatedStorageIO.Default.CreateFile(path);
                }
                else
                {
                    _internal = IsolatedStorageIO.Default.OpenFile(path, FileMode.OpenOrCreate);
                }
                FileStream.HandleTracker.Add(path, _internal);
            }
        }
    

    to

        public FileStream(string path, FileMode mode, FileAccess access, FileShare share, int unused)
        {
            IsolatedStorageFileStream handler = null;
            if(FileStream.HandleTracker.TryGetValue(path, out handler)) 
            {
                _internal = handler;
                if(!_internal.CanRead) 
                {
                    FileStream.HandleTracker.Remove(path);
                    CreateOpenNewFile(path, mode);
                }
            } else {
                CreateOpenNewFile(path, mode);
            }
        }
    
        private void CreateOpenNewFile(string path, FileMode mode) 
        {
            if(mode == FileMode.Create || mode == FileMode.CreateNew) 
            {
                _internal = IsolatedStorageIO.Default.CreateFile(path);
            } else {
                try {
                    _internal = IsolatedStorageIO.Default.OpenFile(path, FileMode.OpenOrCreate);
                } catch(Exception ex) {
                    var v = ex;
                }
            }
            FileStream.HandleTracker.Add(path, _internal);
        }
    

    This is the first time I’m attempting to debug and contribute to an open source project. Any comments or thoughts on these changes will be greatly appreciated.

    Alasdair.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.