Note that there are some explanatory texts on larger screens.

plurals
  1. POMono on OS X: System.Data.SQLite does not work
    primarykey
    data
    text
    <p>I am planning to do a project using Mono and SQLite as the database. Development is to be done primarily on a Mac. I have successfully setup Mono and tested System.Data.SQLite(managed dll). Simple test applications work perfectly.</p> <p>However when I tried to use <code>DataTable</code> in my code it throws a runtime exception. Following is the code snippet:</p> <pre><code>public static void Main (string[] args) { string connectionString = "Data Source=emp.db"; try { using (SQLiteConnection conn = new SQLiteConnection(connectionString)) { string query = "SELECT firstname, lastname FROM employees"; using (SQLiteCommand comm = new SQLiteCommand(query, conn)) { conn.Open(); comm.CommandText = query; using (SQLiteDataReader reader = comm.ExecuteReader()) { while (reader.Read()) { string firstname = reader.GetString(0); string lastname = reader.GetString(1); Console.WriteLine("Name: " + firstname + " " + lastname); } DataTable dt = new DataTable(); dt.Load(reader); // line 39 where problem occurs } } } } catch (Exception e) { Console.WriteLine(e); } } </code></pre> <p>The above code get built successfully but does not run on my development machine and gives the following output on the terminal.</p> <p>The output when I run the application is as below:</p> <pre><code>Name: John Doe Name: Eric Smith System.EntryPointNotFoundException: sqlite3_column_origin_name at (wrapper managed-to-native) System.Data.SQLite.UnsafeNativeMethods:sqlite3_column_origin_name (intptr,int) at System.Data.SQLite.SQLite3.ColumnOriginalName (System.Data.SQLite.SQLiteStatement stmt, Int32 index) [0x00000] in &lt;filename unknown&gt;:0 at System.Data.SQLite.SQLiteDataReader.GetSchemaTable (Boolean wantUniqueInfo, Boolean wantDefaultValue) [0x00000] in &lt;filename unknown&gt;:0 at System.Data.SQLite.SQLiteDataReader.GetSchemaTable () [0x00000] in &lt;filename unknown&gt;:0 at System.Data.Common.DataAdapter.BuildSchema (IDataReader reader, System.Data.DataTable table, SchemaType schemaType, MissingSchemaAction missingSchAction, MissingMappingAction missingMapAction, System.Data.Common.DataTableMappingCollection dtMapping) [0x0003b] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.Data/System.Data.Common/DataAdapter.cs:284 at System.Data.DataTable.Load (IDataReader reader, LoadOption loadOption) [0x0001f] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.Data/System.Data/DataTable.cs:2853 at System.Data.DataTable.Load (IDataReader reader) [0x00011] in /private/tmp/monobuild/build/BUILD/mono-2.10.6/mcs/class/System.Data/System.Data/DataTable.cs:2838 at SQLiteApp.MainClass.Main (System.String[] args) [0x00086] in /Users/nayaabkhan/Projects/SQLiteApp/SQLiteApp/Main.cs:37 </code></pre> <p>I was surprised to see that the same above executable worked perfectly under windows, but was failing on my development machine.</p> <p>Searching on the internet, I found that this problem has to do something with the sqlite dynamic library and must be compiled with SQLITE_ENABLE_COLUMN_METADATA. I've tried to compile sqlite with the SQLITE_ENABLE_COLUMN_METADATA as well. I don't know where to put the compiled <code>libsqlite3.0.dylib</code>.</p> <p>Any help will be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload