database - How to retrieve the last autoincremented ID from a SQLite table? -


I have a table message with column ID (primary key, autocorrect) and content (text).
I have a table with user name (primary key, text) and hash.
A message can be many messages by a recipient (user) and many recipients (user) and recipient (user).
I have created a message message with two columns: Message ID (Referring to the message table and the recipient's ID column (pointing to the username column in the user table) This table contains several recipients and messages So, I have this question, it will be created after a new message ID is stored in the database, but I will get this new MessageID How can I just retain a reference to the added message for retrieving?
I can always search the database for the last line added, but possibly return a different line in the multithreaded environment ?

Edit: As I understand it for SQLite, you can use SELECT last_insert_rowid (), but how do I tell this statement to ADO.NET?

My persistence code (message and message DirectX Databases are):

  Public Zero Continuous (Message Message) {pm_databaseDataSet. Message Message Message; Messagerow = messages.AddMessagesRow (Message.Senders, Messages. Timestent.ToFileTime (), message. Content, message. Timecredits ToFileTime ()); UpdateMessages (); Var x = messagerow; // I suspected that there will be message of a new line in the message row in the message table, but it is not. Foreign Currency (recipients in message recipient. Reciprints) {var row = messagesRecipients.NewMessages_RecipientsRow (); Line. Retrieved = recipient; //row.MessageID= How do I get it? MessagesRecipients.AddMessages_RecipientsRow (line); UpdateMessagesRecipients (); // method not shown}} Private Zero UpdateMessages () {messagesAdapter.Update (message); MessagesAdapter.Fill (messages); }  

With SQL Server you can get SCOPE_IDENTITY () Will select for the current process.

.

To get this value, you want to use SQL or ODDB code in response to your comment like:

 using  (SqlConnection conn = New SqlConnection (connString)) {string sql = "select last_insert_rowid ()"; SqlCommand CMD = New SQL Commands (Esquilla, Con); Conn.Open (); Int lastID = (Int32) cmd.ExecuteScalar (); }  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -