开发者

about SQLite query

开发者 https://www.devze.com 2023-03-07 11:29 出处:网络
I\'m using SQLite & in that i\'m using the following query- INSERT INTO Contact(FirstName, LastName, MobileNumber, IsArchive) VALUES(\'mina\', \'Ambani\', \'9874587458\', 1); SELECT last_insert_r

I'm using SQLite & in that i'm using the following query-

INSERT INTO Contact(FirstName, LastName, MobileNumber, IsArchive) VALUES('mina', 'Ambani', '9874587458', 1); SELECT last_insert_rowid() AS 'Identity';
开发者_开发问答

this query insert the record & also gives last insert row id of identity column in my table but initially it generates error as-

The following errors were encountered while parsing the contents of the SQL pane:

Unable to parse query text

How to remove this error?

thanks.


Sqlite does not seem to support multiple SQL statements in one query. Run a separate subsequent query. Something like

SQLiteCommand IDCmd = new SQLiteCommand("Select last_insert_rowid();", conn);
cmd.ExecuteNonQuery(); // EXECUTE INSERT HERE
long id = (long)IDCmd.ExecuteScalar();

Connection open/close and error handling is missing from this example.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号