MySql and inserting last ID problem remains

后端 未结 3 1181
南旧
南旧 2020-12-20 06:45

Ok after much reading and trying I still cant seem to get this to work:

      OdbcCommand cmd = new OdbcCommand(\"INSERT INTO User (Email) VALUES (\'rusty@ms         


        
3条回答
  •  清歌不尽
    2020-12-20 07:05

    A workaround:

    1. Add an out param to your query:
    2. inside the query use SET @OpParam = SELECT LAST_INSERT_ID();
    3. In your code get it as if ((int)@OpParam.Value > 0){ pull out }.
    4. Also, if run select then instead NonQuery, use ExecuteScalar().

    Hope it might help you.

提交回复
热议问题