c# - whats the right version for using either scope_identity() ,@@identity (),last_insert_id() in mysql -


im working on asp.net c# ,i tried 3 of them none worked , sql error(you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'select last_insert_id()') query:

                string st = ("insert `service` values ('','" + noms + "','" + desc + "','3','" + ad + "','" + vil + "','" + pays + "')"+" select scope_identity()"); 

you can use lastinsertedid property of mysqlcommand :

// cmd mysqlcommand objet cmd.executenonquery(); long lastinsertedid = cmd.lastinsertedid; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -