加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何在SQLite中的insert查询中返回自动增量值?

发布时间:2020-12-15 04:22:06 所属栏目:百科 来源:网络整理
导读:在我的项目中,我使用 System.Data.SQLite.数据库有表格标签,其中包含自动增量主要字段ID(类型为整数).我写的时候: using (SQLiteCommand command = conn.CreateCommand()){ command.CommandText = "insert into Tags(name) values(@name) returning into @i
在我的项目中,我使用 System.Data.SQLite.数据库有表格标签,其中包含自动增量主要字段ID(类型为整数).我写的时候:
using (SQLiteCommand command = conn.CreateCommand())
{
   command.CommandText = "insert into Tags(name) values(@name) returning into @id";
   command.Parameters.Add("@id",DbType.Int32).Direction = ParameterDirection.Output;
   command.ExecuteNonQuery();
}

Visual Studio表示不支持该操作.怎么解决?

在线发生错误:

command.Parameters.Add("@id",DbType.Int32).Direction = ParameterDirection.Output;

解决方法

我找到了工作查询:
SELECT last_insert_rowid()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读