On Sep 14, 2011, at 5:05 PM, Mittchel wrote:
> Why would you want to bundle it with your app? What are the pros and cons?
It would certainly be easier to ship a "pre-canned" version than to do it in
code (less/no duplication, etc.). It just has additional startup overhead (do
it in a separate thread ;-)
> Could you maybe illustrate me a method that executes a simple select query
> and returns the amount of rows? For say like a login method.. I tryed to find
> methods for that in sqlite but didnt succeed..
This was MonoTouch-specific, but the core SELECTs/etc. are cross-platform:
https://github.com/xamarin/monotouch-samples/blob/master/MonoCatalog-MonoDevelop/MonoDataSqlite.xib.cs
Granted, it's using a WithCommand() helper, but the intent should be clear. For
example, to get an item count:
//
https://github.com/xamarin/monotouch-samples/blob/master/MonoCatalog-MonoDevelop/MonoDataSqlite.xib.cs#L211
WithCommand (c => {
c.CommandText = "SELECT COUNT(*) FROM [Items]";
var r = c.ExecuteReader ();
while (r.Read ()) {
count = (int) (long) r [0];
}
});
To select data:
//
https://github.com/xamarin/monotouch-samples/blob/master/MonoCatalog-MonoDevelop/MonoDataSqlite.xib.cs#L162
string query = string.Format ("SELECT [Key], [Value] FROM [Items] LIMIT
{0},1", indexPath.Row);
string key = null, value = null;
WithCommand (c => {
c.CommandText = query;
var r = c.ExecuteReader ();
while (r.Read ()) {
key = r ["Key"].ToString ();
value = r ["Value"].ToString ();
}
});
It's ye-olde ADO.NET.
- Jon
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid