Getting Exception When Using SqliteNet
I keep getting an error when attempting to do anything with sqliteNET. I get exception: near ')': syntax error at SQLite.SQLite3.Prepare2 (IntPtr db, System.String query) [0x0002
Solution 1:
Are you using the most recent SQLite-net? There are lots of people distributing the library, but there is only one official version, the source:
https://github.com/praeclarum/sqlite-net/tree/master/src
(Soon there will be a nice PCL official release, but we're still working through some bugs.)
I just wrote this test app and everything works fine:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using SQLite;
namespace SO24247435
{
public class URMMobileAccount
{
[PrimaryKey, AutoIncrement]
public int URMID {get;set;}
public int Id {get; set;}
public string Username {get; set;}
public string Password {get; set;}
public string Type {get; set;}
public Nullable<int> TypeId {get; set;}
public bool IsValid {get; set;}
}
[Register ("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
using (var db = new SQLiteConnection (
Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments),"test.sqlite")))
{
try
{
db.CreateTable<URMMobileAccount> ();
var localAccount = db.Query<URMMobileAccount> ("Select * from URMMobileAccount");
if (localAccount.Any ())
{
Console.WriteLine (localAccount [0].Username);
}
}
catch (Exception ex)
{
Console.WriteLine (ex);
}
}
window = new UIWindow (UIScreen.MainScreen.Bounds);
// window.RootViewController = myViewController;
window.MakeKeyAndVisible ();
return true;
}
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
}
}
Post a Comment for "Getting Exception When Using SqliteNet"