As promised, the Corp411 sample app has been 'converted' from sqlite-net to System.Data. MonoTouch 1.2 isn't quite out yet, so you must follow the instructions on this page to download the
System.Data assemblies to your installation, put them in the correct place AND add references to your MonoDevelop solution for
Mono.Data.Sqlite.dll, Mono.Data.Tds.dll, System.Data.dll, System.Transactions.dll (I'm not sure if they're all required, but it seemed like a sensible set).
It's pretty easy to use after all that:
// db is the path to the SQLite database fileand
var conn = new SqliteConnection("Data Source=" + db);
listData = new List<Employee>();Cool eh? Doesn't that look familiar... good old ADO.NET :-)
// System.Data from http://monotouch.net/Documentation/System.Data
var sd = new SystemDataHelper("phonebook");
var connection = sd.GetConnection();
using (var cmd = connection.CreateCommand())
cmd.CommandText = "SELECT Firstname, Lastname, Work, Mobile,"
+ " Department, Email "
+ " FROM Phonebook ORDER BY Lastname";
using (var reader = cmd.ExecuteReader ())
while (reader.Read ())
var emp = new Employee();
emp.Firstname = (string)reader["Firstname"];
emp.Lastname = (string)reader["Lastname"];
emp.Work = (string)reader["Work"];
emp.Mobile = (string)reader["Mobile"];
emp.Department = (string)reader["Department"];
emp.Email = (string)reader["Email"];
That's a small part of the
System.Datanamespace, so the code is pretty small :) here 'tis Corp411.3.zip (38Kb)
... and proof it runs on a device ...