public int AddSale(SaleModel model) { int id = 0 ; string query = " select @@identity " ; string sqlText = string .Format( " insert into Sale(SCount,SumMoney,SUser,SJoinTime,Hide) values ('{0}','{1}','{2}','{3}',0) " , model.SCount, model.SumMoney, model.SUser, model.SJoinTime); // LogWrite(sqlText); OleDbCommand cmd = new OleDbCommand(sqlText, conn); conn.Open(); cmd.ExecuteNonQuery(); cmd.CommandText = query; id = ( int )cmd.ExecuteScalar(); conn.Close(); return id; }