我有一個使用sqlite客戶端的應用程序。在應用程序中,我將數據插入表中,並且需要自動遞增的Id。無論如何要在executivetenonquery中獲得id? s.th喜歡sqlparameter或...如何在wp中插入一行並在sqlite中返回自動增量值?
我正在使用下面的方法來獲取數據,我認爲rec變量持有的id,但它始終rec = 1,我不知道這是什麼好?
int x= (System.Windows.Application.Current as App).db.Insert
<CsWidget>(ObjWidget, @"Insert into Tbl_Widget (Name) values(@Name");
public int Insert<T>(T obj, string statement) where T : new()
{
Open();
SQLiteCommand cmd = db.CreateCommand(statement);
int rec = cmd.ExecuteNonQuery(obj);
return rec;
}
我甚至在發言結束時添加SELECT last_insert_rowid(),但我不知道如何獲取該值 – Finutv
無關的評論:在移動設備上親愛的上帝,爲什麼有staight式SQL使用RDMBS命令。只需使用Linq2SQL。 – JustinAngel
我是Windows開發新手,這是我發現的「很好的參考」。所以這將是很好,如果你可以給我一個更多的海峽鏈接/引用我可以開始 – Finutv