我正在尝试使用Xamarin.Android创建一个简单的本地SQLite数据库。该代码是:
string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
SQLiteConnectiondb = new SQLiteConnection (Path.Combine (folder, "Experimental.db"));
db.CreateTable<Employee>();
我的员工班级是:
[Table("Employees")]
public class Employee
{
[PrimaryKey, AutoIncrement]
int Id { get; set; }
string Name { get; set; }
}
每当代码到达db.CreateTable时,我得到的异常是:
SQLite.SQLiteException: near ")": syntax error
at at SQLite.SQLite3.Prepare2 (intptr,string) <IL 0x0002c, 0x00160>
at at SQLite.SQLiteCommand.Prepare () <IL 0x00011, 0x0008f>
at at SQLite.SQLiteCommand.ExecuteNonQuery () <IL 0x00013, 0x000b3>
at at SQLite.SQLiteConnection.Execute (string,object[]) <IL 0x00041, 0x001ab>
at at SQLite.SQLiteConnection.CreateTable (System.Type,SQLite.CreateFlags) <IL 0x000a4, 0x005cb>
at at SQLite.SQLiteConnection.CreateTable<Core.Employee> (SQLite.CreateFlags) <0x00063>
在我的经验不足的人看来,这确实看起来像是与SQLite本身有关的问题。还有其他人遇到过这个问题吗?如果是这样-您的解决方法是什么?
公开Employee类的属性,以便SQLite在创建表的列时可以看到它们:
[Table("Employees")]
public class Employee
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句