I'm creating a Maria DB project (MySQL) using C#, and I have a need to get the primary key Id from a row I just insert into a table.
I've looked at several solutions on the internet and I'm not having any success. They are either unreliable (documented errors) or do not work with MySql/Maria.
This is my last effort:
MySqlCommand cmd = new MySqlCommand("INSERT INTO bbb.traveldocuments (CustomerID,TDNumber,TDDateCreated,TDMoveStart,TDMoveEnd,TDJobNumber,TDPermitType,TDNotes)" + "VALUES(@CustomerID,@TDNumber,@TDDateCreated,@TDMoveStart,@TDMoveEnd,@TDJobNumber,@TDPermitType,@TDNotes); SELECT SCOPE_IDENTITY() ", con);
int insertedID = Convert.ToInt32(cmd.ExecuteScalar());
When I run the above code I get:
MySql.Data.MySqlClient.MySqlException: 'FUNCTION SCOPE_IDENTITY does not exist'
Are there any suggestions I can try?
Thank you in advance.