how to get the last record number after inserting record to database in access

前端 未结 5 721
[愿得一人]
[愿得一人] 2021-02-05 21:40

i have database in access with auto increase field (ID).

i insert record like this (in C#)

SQL = \"insert into TermNumTbl (DeviceID,IP) valu         


        
5条回答
  •  心在旅途
    2021-02-05 22:19

    I like more indicate the type of command is very similar to the good solution provided by Pranay Rana

    using (OleDbCommand cmd = new OleDbCommand())
                        {
                            cmd.CommandType = CommandType.Text;
                            cmd.CommandText = sql_Insert;
                            cmd.ExecuteNonQuery();
    
                            cmd.CommandText = sql_obtainID;
                            resultado = (int)comando.ExecuteScalar();
                        }
    

提交回复
热议问题