啥也不說了,剛剛研究出來滴~~~貼碼:
/// <summary>插入
/// 傳回剛剛插入的ID
/// </summary>
/// <param name="groupname"></param>
/// <param name="gid"></param>
/// <returns></returns>
public bool Insert(string groupname, out string gid)
{
string sql = "insert into groupca(groupname) values(@groupname);select last_insert_rowid();";
helper.CreateCommand(sql);
helper.AddParameter("@groupname", groupname as object);
string res = helper.ExecuteScalar();
if (!string.IsNullOrEmpty(res))
{
gid = res;
return true;
}
else
gid = "0";
return false;
}
上面的代碼用到了自己之前建立的一個SQLITE資料庫的操作類,當然,最主要的就是那一句語句了,其實select last_insert_rowid();也就相當于MSSQL中的select @@identity;