title: Howto to access the tables of an attached database?
body: <p>I am using sqlite-winrt on a Windows Phone 8 project to work with SQLite databases. Works quite will, except a problem with attached databases:</p>
  
  <p>There are two identical database (same tables, different content) A and B. B is attached to A:</p>
  
  <pre><code>database dbA = new  Database(dbAFile);
  await dbA.OpenAsync();
  
  await dbA.ExecuteStatementAsync("ATTACH B.sqlite AS AttachDB");
  
  query = "SELECT * FROM SomeTable";
  using (Statement sqlStatement = await dbA.PrepareStatementAsync(query)) {
     while (await sqlStatement.StepAsync()) {
        ...List Content of SomeTable in Table A --&gt; No Problem
     }
  }
  
  query = "SELECT * FROM AttachDB.SomeTable";
  using (Statement sqlStatement = await dbA.PrepareStatementAsync(query)) {
     while (await sqlStatement.StepAsync()) {
        ...List Content of SomeTable in Table B --&gt; Crash in PrepareStatementAsync
     }
  }
  </code></pre>
  
  <p>When using to access the Table "SomeTable" in the attached database an Exception is thrown when preparing the statment. The Exception does not show the source of the problem but I managed to get the SQL error message, which is:</p>
  
  <p><strong>"no such table: AttachDB.SomeTable"</strong></p>
  
  <p>Of course database B has a Table "SomeTable". When I connect to this database directly I can access table "SomeTable" without any problem. </p>
  
  <p>I thought that I could be a problem that B has exactly the same tables as A and create a table "OnlyInB" in B. But accessing AttachDB.OnlyInB also fails. According to the sqlite doc one can skip the database name when the table name is unique. Thus "OnlyInB" should work as well. But is does not. "SELECT * FROM OnlyInB" shows <strong>"no such table: OnlyInB"</strong></p>
  
  <p>I testes the same scenation with the "SQLite Manager" Extension of Firefox (opened A, attached, B...) Selecting Data from AttachDB.SomeTable or any other table in B is not problem there. The Problem only occurs when using sqlite-winrt.</p>
  
  <p>I also tested if there could be any problem with attaching B to A. But there isn't. When I try to attach B twice or to attach a third database using "AttachDB" again an error is shown that clearly states that B is correctly attached to A. The attaching seems to work perfect, except the problem that I cannot access any tables in B...</p>
  
  <p>Any advise?
  Thank you very much!</p>