Table of contents
MonoTouch 1.2 adds preview support for System.Data, including the
ExampleThe following program creates a database in using System;
using System.Data;
using System.IO;
using Mono.Data.Sqlite;
class Demo {
static void Main (string [] args)
{
var connection = GetConnection ();
using (var cmd = connection.CreateCommand ()) {
connection.Open ();
cmd.CommandText = "SELECT * FROM People";
using (var reader = cmd.ExecuteReader ()) {
while (reader.Read ()) {
Console.Error.Write ("(Row ");
Write (reader, 0);
for (int i = 1; i < reader.FieldCount; ++i) {
Console.Error.Write(" ");
Write (reader, i);
}
Console.Error.WriteLine(")");
}
}
connection.Close ();
}
}
static SqliteConnection GetConnection()
{
var documents = Environment.GetFolderPath (
Environment.SpecialFolder.Personal);
string db = Path.Combine (documents, "mydb.db3");
bool exists = File.Exists (db);
if (!exists)
SqliteConnection.CreateFile (db);
var conn = new SqliteConnection("Data Source=" + db);
if (!exists) {
var commands = new[] {
"CREATE TABLE People (PersonID INTEGER NOT NULL, FirstName ntext, LastName ntext)",
"INSERT INTO People (PersonID, FirstName, LastName) VALUES (1, 'First', 'Last')",
"INSERT INTO People (PersonID, FirstName, LastName) VALUES (2, 'Dewey', 'Cheatem')",
"INSERT INTO People (PersonID, FirstName, LastName) VALUES (3, 'And', 'How')",
};
foreach (var cmd in commands)
using (var c = conn.CreateCommand()) {
c.CommandText = cmd;
c.CommandType = CommandType.Text;
conn.Open ();
c.ExecuteNonQuery ();
conn.Close ();
}
}
return conn;
}
static void Write(SqliteDataReader reader, int index)
{
Console.Error.Write("({0} '{1}')",
reader.GetName(index),
reader [index]);
}
}
Missing FunctionalityBoth System.Data and Mono.Data.Sqlite are missing some functionality. System.DataFunctionality missing from System.Data.dll consists of:
Mono.Data.SqliteMeanwhile, Mono.Data.Sqlite.dll suffered no source code changes, but instead may be host to a number of runtime issues (the primary reason this is a preview release). Thus, the real question is this: what's missing in SQLite 3.0? The following functions are used by
Where are these functions used (i.e. what can't you use from Data BindingData Binding is not supported at this time. |