title: Linq to SQL with Mono: Can't connect to my sqlite database
body: <p>I would like to access an sqlite database from mono:
  The database is stored in the file "languages.sqlite" and contains the table "spanish-german".</p>
  
  <ul>
  <li>I installed the monodevelop database addin</li>
  <li>I created a database connection - with the IDE tool</li>
  <li><p>Then tested this connection - with the IDE tool query database.</p>
  
  <p>select * from "spanish-german"</p></li>
  </ul>
  
  <blockquote>
    <p>"hablar| sprechen"</p>
    
    <p>"hacer | machen,tun"</p>
  </blockquote>
  
  <p>The table has two columns, one with the spanish word and one with the german translation</p>
  
  <ul>
  <li>I created a LINQ class - with the IDE. The output looks good. A class for the database and another for the table was created.</li>
  </ul>
  
  <p>Now I need to connect to the database in my code. This should be rather straightforward, but I can't get it to work. Here's my code:</p>
  
  <pre><code>string connectionString = "Data Source=languages.sqlite";
  
  DataContext dataContext = new DataContext (connectionString);
  Table&lt;Spanish_German&gt; words = dataContext.GetTable&lt;Spanish_German&gt; ();
  
  var query =from word in words select word;
  
  foreach (var word in query)
      Console.WriteLine (word.Spanish);
  </code></pre>
  
  <p>This compiles just fine, but when run, the code halts at the final print statement.</p>
  
  <blockquote>
    <p>System.Data.SqlClient.SqlConnection.Open()  "filename unknown"</p>
  </blockquote>
  
  <p>Apparently the filename was incorrect. The database is stored in a folder databases.
  I tried the following connectionstrings:</p>
  
  <ul>
  <li>"languages.sqlite"</li>
  <li>"databases/languages.sqlite"</li>
  <li>"languages"</li>
  <li>"databases/languages"</li>
  <li>"Data Source=languages.sqlite"</li>
  <li>"Data Source=databases/languages.sqlite"</li>
  <li>"Data Source =languages"</li>
  <li>"Data Source = databases/languages"</li>
  </ul>
  
  <p>And then found out that MS has a custom format for these strings and "Data Source" should be called "Addr". So now I'm using
   - "Addr=languages.sqlite"</p>
  
  <p>And am getting a different exception:</p>
  
  <blockquote>
    <p>Mono.Data.Tds.TdsInternalException has been thrown. Server closed the connection.</p>
  </blockquote>
  
  <p>What is that ? How can I fix it ?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I changed the build option for the database to "content" and had it copied to the output directory. Then I added "Version=3;" to the connectionString. And finally I changed the dataContext to use sqLite.</p>
  
  <p>With all three changes the program works, if one of them is left out, it doesn't.</p>
  
  <p>Thank you very much. If one of you would create an answer out of his comment, I would accept it.</p>