【发布时间】:2011-04-19 04:35:08
【问题描述】:
在我的项目中,我使用System.Data.SQLite。数据库有表Tags,其中包含自动增量主字段ID(类型Integer)。当我写:
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()”含糊不清。 @name 是如何设置的? “SELECT last_insert_rowid()”去哪儿了?旁白:您为 Calibre 添加了哪些功能? ;)
-
我想,你不能设置@name。您的密钥必须具有名称“Id”。 "SELECT last_insert_rowid()" 与最后插入一起使用。
标签: c# sqlite auto-increment